Make jump_to_playing_song not runnable if there is no playing song

This commit is contained in:
Andrzej Rybczak
2017-01-11 04:44:26 +01:00
parent cd414810a5
commit a5827cf1de
3 changed files with 11 additions and 9 deletions

View File

@@ -1204,27 +1204,26 @@ void UpdateDatabase::run()
bool JumpToPlayingSong::canBeRun()
{
return myScreen == myPlaylist
|| myScreen == myBrowser
|| myScreen == myLibrary;
m_song = myPlaylist->nowPlayingSong();
return !m_song.empty()
&& (myScreen == myPlaylist
|| myScreen == myBrowser
|| myScreen == myLibrary);
}
void JumpToPlayingSong::run()
{
auto s = myPlaylist->nowPlayingSong();
if (s.empty())
return;
if (myScreen == myPlaylist)
{
myPlaylist->locateSong(s);
myPlaylist->locateSong(m_song);
}
else if (myScreen == myBrowser)
{
myBrowser->locateSong(s);
myBrowser->locateSong(m_song);
}
else if (myScreen == myLibrary)
{
myLibrary->locateSong(s);
myLibrary->locateSong(m_song);
}
}

View File

@@ -682,6 +682,8 @@ struct JumpToPlayingSong: BaseAction
private:
virtual bool canBeRun() override;
virtual void run() override;
MPD::Song m_song;
};
struct ToggleRepeat: BaseAction