[vlc-commits] Qt: menus: do not store QModelIndex.

Francois Cartegnie git at videolan.org
Sat Sep 7 12:58:02 CEST 2013


vlc/vlc-2.1 | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Sep  6 15:22:23 2013 +0200| [cdadfe411feb3ba37d7587dc21a87bd8c4d13ed1] | committer: Jean-Baptiste Kempf

Qt: menus: do not store QModelIndex.

(cherry picked from commit 666851ce3af8f910daa63358797b196771f8302a)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/gui/qt4/util/qmenuview.cpp |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/modules/gui/qt4/util/qmenuview.cpp b/modules/gui/qt4/util/qmenuview.cpp
index 909cbb5..8f783bf 100644
--- a/modules/gui/qt4/util/qmenuview.cpp
+++ b/modules/gui/qt4/util/qmenuview.cpp
@@ -30,7 +30,6 @@
 #include <QVariant>
 #include <assert.h>
 
-
 /***
  * This is a simple view, like a QListView, but displayed as a QMenu
  * So far, this is quite limited.
@@ -41,7 +40,7 @@
  *       - deal with a root item
  ***/
 
-Q_DECLARE_METATYPE(QModelIndex); // So we can store it in a QVariant
+Q_DECLARE_METATYPE(QPersistentModelIndex); // So we can store it in a QVariant
 
 QMenuView::QMenuView( QWidget * parent, int _iMaxVisibleCount )
           : QMenu( parent ), iMaxVisibleCount( _iMaxVisibleCount )
@@ -107,7 +106,7 @@ QAction* QMenuView::createActionFromIndex( QModelIndex index )
     action->setEnabled( index.flags().testFlag( Qt::ItemIsEnabled ) );
 
     /* */
-    QVariant variant; variant.setValue( index );
+    QVariant variant; variant.setValue( QPersistentModelIndex( index ) );
     action->setData( variant );
 
     return action;
@@ -119,9 +118,9 @@ void QMenuView::activate( QAction* action )
     assert( m_model );
 
     QVariant variant = action->data();
-    if( variant.canConvert<QModelIndex>() )
+    if( variant.canConvert<QPersistentModelIndex>() )
     {
-        emit activated( variant.value<QModelIndex>());
+        emit activated( variant.value<QPersistentModelIndex>());
     }
 }
 



More information about the vlc-commits mailing list