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

1
NEWS
View File

@@ -19,6 +19,7 @@ ncmpcpp-0.8 (????-??-??)
* Lyrics and last_fm can now be startup screens and are lockable.
* Action 'update_environment' now also synchronizes status with MPD.
* Fixed an issue that could cause some MPD events to be missed.
* ACtion 'jump_to_playing_song' is not runnable now if there is no playing song.
ncmpcpp-0.7.7 (2016-10-31)
* Fixed compilation on 32bit platforms.

View File

@@ -1204,27 +1204,26 @@ void UpdateDatabase::run()
bool JumpToPlayingSong::canBeRun()
{
return myScreen == myPlaylist
m_song = myPlaylist->nowPlayingSong();
return !m_song.empty()
&& (myScreen == myPlaylist
|| myScreen == myBrowser
|| myScreen == myLibrary;
|| 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