[vlc-commits] gui/qt: fix PLModel::isSupportedaction( ACTION_EXPLORE, ... )

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:21:09 2016 +0200| [8fb83a5fd33a39125caa28af8dd91d8c6de0376e] | committer: Francois Cartegnie

gui/qt: fix PLModel::isSupportedaction( ACTION_EXPLORE, ... )

It is not enough to simply check if an item's URI starts with "file://"
as it will lead to false-negatives. As an example, if the associated
item has a MRL starting with "file/es://...", we would consider it not
to be part of the local file-system (and as such, we do not provide the
option to explore the associated directory).

This commit fixes the issue by invoking vlc_uri2path, if we get a a
non-NULL pointer as the returned value, the item in question resides in
under a path that is suitable for exploration.

As a note; using vlc_uri2path is what is being done when ACTION_EXPLORE
is actually initiated - this commit can as such be viewed as creating
symmetry between checking if it is a supported action, and invoking it.

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

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

 modules/gui/qt/components/playlist/playlist_model.cpp |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/gui/qt/components/playlist/playlist_model.cpp b/modules/gui/qt/components/playlist/playlist_model.cpp
index dd64a13..ff9c98a 100644
--- a/modules/gui/qt/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt/components/playlist/playlist_model.cpp
@@ -34,6 +34,7 @@
 #include "recents.hpp"                                  /* Open:: */
 
 #include <vlc_intf_strings.h>                           /* I_DIR */
+#include <vlc_url.h>
 
 #include "sorting.h"
 
@@ -1040,7 +1041,14 @@ bool PLModel::isSupportedAction( actions action, const QModelIndex &index ) cons
     case ACTION_REMOVE:
         return index != rootIndex() && !item->readOnly();
     case ACTION_EXPLORE:
-            return getURI( index ).startsWith( "file://" );
+    {
+        if( !item )
+            return false;
+
+        char*  psz_path = vlc_uri2path( qtu( item->getURI().toString() ) );
+        free(  psz_path );
+        return psz_path != NULL;
+    }
     case ACTION_CREATENODE:
             return canEdit() && isTree() && ( !item || !item->readOnly() );
     case ACTION_RENAMENODE:



More information about the vlc-commits mailing list