[vlc-commits] gui/qt: fix PLModel::isSupportedAction( ACTION_PLAY, ... )

Filip Roséen git at videolan.org
Sun Jul 24 20:39:14 CEST 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Sun Jul 24 15:09:57 2016 +0200| [c5f7d8ef66c790d32f9fb912a6464d9c28dfce23] | committer: Francois Cartegnie

gui/qt: fix PLModel::isSupportedAction( ACTION_PLAY, ... )

Prior to this commit, ACTION_PLAY was supported if:

    - the index was not associated with the currently playing
      item, or;
    - the playlist was paused.

In other words, the option would not be enabled if the playlist was in
a stopped state.

This commit changes the associated logic to the following, meaning
that the action is supported:

    - when the user has right-clicked on an entity, and;
    - the playlist is either stopped or paused, and;
    - the associated index is not currently playing.

Usage of PL_LOCK/PL_UNLOCK has also been replaced by vlc_playlist_lock
to aid code-reasoning and maintenance.

Signed-off-by: Francois Cartegnie <fcvlcdev at free.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c5f7d8ef66c790d32f9fb912a6464d9c28dfce23
---

 modules/gui/qt/components/playlist/playlist_model.cpp |   15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt/components/playlist/playlist_model.cpp b/modules/gui/qt/components/playlist/playlist_model.cpp
index 54f3253..0ea1acc 100644
--- a/modules/gui/qt/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt/components/playlist/playlist_model.cpp
@@ -1014,10 +1014,17 @@ bool PLModel::isSupportedAction( actions action, const QModelIndex &index ) cons
         return rowCount();
     case ACTION_PLAY:
     {
-        PL_LOCK;
-        bool b_ret = !isCurrent( index ) || playlist_Status(THEPL) == PLAYLIST_PAUSED;
-        PL_UNLOCK;
-        return b_ret;
+        if( !item )
+            return false;
+
+        {
+            vlc_playlist_locker pl_lock ( THEPL );
+
+            if( playlist_Status( THEPL ) != PLAYLIST_RUNNING )
+                return true;
+        }
+
+        return !isCurrent( index );
     }
     case ACTION_PAUSE:
     {



More information about the vlc-commits mailing list