From a5827cf1de3b37aae7294f1f0fed40d3d3431382 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 11 Jan 2017 04:44:26 +0100 Subject: [PATCH] Make jump_to_playing_song not runnable if there is no playing song --- NEWS | 1 + src/actions.cpp | 17 ++++++++--------- src/actions.h | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 78e97be6..3d8c1069 100644 --- a/NEWS +++ b/NEWS @@ -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. diff --git a/src/actions.cpp b/src/actions.cpp index c77466cc..e66b9a69 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -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); } } diff --git a/src/actions.h b/src/actions.h index e24ce27b..e83c0a79 100644 --- a/src/actions.h +++ b/src/actions.h @@ -682,6 +682,8 @@ struct JumpToPlayingSong: BaseAction private: virtual bool canBeRun() override; virtual void run() override; + + MPD::Song m_song; }; struct ToggleRepeat: BaseAction