actions: locate song: fix crash (hopefully for the last time)
This commit is contained in:
@@ -1149,13 +1149,11 @@ void TogglePlayingSongCentering::run()
|
||||
Statusbar::printf("Centering playing song: %1%",
|
||||
Config.autocenter_mode ? "on" : "off"
|
||||
);
|
||||
if (Config.autocenter_mode
|
||||
&& Status::State::player() != MPD::psUnknown
|
||||
&& !myPlaylist->main().isFiltered())
|
||||
if (Config.autocenter_mode && !myPlaylist->main().isFiltered())
|
||||
{
|
||||
auto sp = Status::State::currentSongPosition();
|
||||
if (sp >= 0 && size_t(sp) < myPlaylist->main().size())
|
||||
myPlaylist->main().highlight(Status::State::currentSongPosition());
|
||||
auto s = myPlaylist->nowPlayingSong();
|
||||
if (!s.empty())
|
||||
myPlaylist->main().highlight(s.getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1176,25 +1174,24 @@ bool JumpToPlayingSong::canBeRun() const
|
||||
return ((myScreen == myPlaylist && !myPlaylist->isFiltered())
|
||||
|| myScreen == myBrowser
|
||||
|| myScreen == myLibrary)
|
||||
&& Status::State::player() != MPD::psUnknown;
|
||||
&& !myPlaylist->nowPlayingSong().empty();
|
||||
}
|
||||
|
||||
void JumpToPlayingSong::run()
|
||||
{
|
||||
auto s = myPlaylist->nowPlayingSong();
|
||||
if (myScreen == myPlaylist)
|
||||
{
|
||||
auto sp = Status::State::currentSongPosition();
|
||||
if (sp >= 0 && size_t(sp) < myPlaylist->main().size())
|
||||
myPlaylist->main().highlight(Status::State::currentSongPosition());
|
||||
myPlaylist->main().highlight(s.getPosition());
|
||||
}
|
||||
else if (myScreen == myBrowser)
|
||||
{
|
||||
myBrowser->LocateSong(myPlaylist->nowPlayingSong());
|
||||
myBrowser->LocateSong(s);
|
||||
drawHeader();
|
||||
}
|
||||
else if (myScreen == myLibrary)
|
||||
{
|
||||
myLibrary->LocateSong(myPlaylist->nowPlayingSong());
|
||||
myLibrary->LocateSong(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -249,9 +249,11 @@ MPD::SongList Playlist::getSelectedSongs()
|
||||
MPD::Song Playlist::nowPlayingSong()
|
||||
{
|
||||
MPD::Song s;
|
||||
if (Status::State::player() != MPD::psStop)
|
||||
if (Status::State::player() != MPD::psUnknown)
|
||||
withUnfilteredMenu(w, [this, &s]() {
|
||||
s = w.at(Status::State::currentSongPosition()).value();
|
||||
auto sp = Status::State::currentSongPosition();
|
||||
if (sp >= 0 && size_t(sp) < w.size())
|
||||
s = w.at(sp).value();
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user