[vlc-commits] Qt: fix playlist issues when Qt works as a dialog provider

Erwan Tulou git at videolan.org
Mon Jan 20 16:16:33 CET 2014


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Mon Jan 20 14:37:03 2014 +0100| [bb964cd57718aa0c40a01d7600955e9e07c6835d] | committer: Erwan Tulou

Qt: fix playlist issues when Qt works as a dialog provider

For the Qt plugin to keep on working both as an interface module and
a dialog/menu/extension provider, the new implementation of pl_Get( p_intf )
can no longer be used blindly, since it now assumes that the playlist is the
parent object. In the latter case, the parent object is the calling interface
(for instance, skins2) and the playlist is actually the grandparent !

As a rule of thumb, THEPL which is now initialized appropriately should be
used instead of pl_Get( p_intf ) throughout Qt.

This fixes trac #10421

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

 modules/gui/qt4/components/controller_widget.cpp       |    2 +-
 modules/gui/qt4/components/extended_panels.cpp         |    6 +++---
 modules/gui/qt4/components/info_panels.cpp             |    3 +--
 modules/gui/qt4/components/playlist/ml_model.cpp       |    2 +-
 modules/gui/qt4/components/playlist/playlist_model.cpp |    2 +-
 modules/gui/qt4/input_manager.cpp                      |    4 ++--
 modules/gui/qt4/qt4.cpp                                |   10 ++++++++--
 modules/gui/qt4/qt4.hpp                                |    3 ++-
 8 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/modules/gui/qt4/components/controller_widget.cpp b/modules/gui/qt4/components/controller_widget.cpp
index 66fecd9..db27f3b 100644
--- a/modules/gui/qt4/components/controller_widget.cpp
+++ b/modules/gui/qt4/components/controller_widget.cpp
@@ -190,7 +190,7 @@ void SoundWidget::showVolumeMenu( QPoint pos )
 void SoundWidget::setMuted( bool mute )
 {
     b_is_muted = mute;
-    playlist_t *p_playlist = pl_Get( p_intf );
+    playlist_t *p_playlist = THEPL;
     playlist_MuteSet( p_playlist, mute );
 }
 
diff --git a/modules/gui/qt4/components/extended_panels.cpp b/modules/gui/qt4/components/extended_panels.cpp
index 3604034..84d16ae 100644
--- a/modules/gui/qt4/components/extended_panels.cpp
+++ b/modules/gui/qt4/components/extended_panels.cpp
@@ -398,7 +398,7 @@ static void ChangeVFiltersString( struct intf_thread_t *p_intf, const char *psz_
     /* Try to set on the fly */
     if( !strcmp( psz_filter_type, "video-splitter" ) )
     {
-        playlist_t *p_playlist = pl_Get( p_intf );
+        playlist_t *p_playlist = THEPL;
         var_SetString( p_playlist, psz_filter_type, psz_string );
     }
     else
@@ -714,7 +714,7 @@ void ExtV4l2::showEvent( QShowEvent *event )
 
 void ExtV4l2::Refresh( void )
 {
-    vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" );
+    vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( THEPL, "v4l2" );
     help->hide();
     if( box )
     {
@@ -877,7 +877,7 @@ void ExtV4l2::ValueChange( bool value )
 void ExtV4l2::ValueChange( int value )
 {
     QObject *s = sender();
-    vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( pl_Get(p_intf), "v4l2" );
+    vlc_object_t *p_obj = (vlc_object_t*)vlc_object_find_name( THEPL, "v4l2" );
     if( p_obj )
     {
         QString var = s->objectName();
diff --git a/modules/gui/qt4/components/info_panels.cpp b/modules/gui/qt4/components/info_panels.cpp
index ddfe308..fcc4f4e 100644
--- a/modules/gui/qt4/components/info_panels.cpp
+++ b/modules/gui/qt4/components/info_panels.cpp
@@ -307,8 +307,7 @@ void MetaPanel::saveMeta()
     input_item_SetPublisher( p_input, qtu( publisher_text->text() ) );
     input_item_SetDescription( p_input, qtu( description_text->toPlainText() ) );
 
-    playlist_t *p_playlist = pl_Get( p_intf );
-    input_item_WriteMeta( VLC_OBJECT(p_playlist), p_input );
+    input_item_WriteMeta( VLC_OBJECT(THEPL), p_input );
 
     /* Reset the status of the mode. No need to emit any signal because parent
        is the only caller */
diff --git a/modules/gui/qt4/components/playlist/ml_model.cpp b/modules/gui/qt4/components/playlist/ml_model.cpp
index a33a4ea..0b18255 100644
--- a/modules/gui/qt4/components/playlist/ml_model.cpp
+++ b/modules/gui/qt4/components/playlist/ml_model.cpp
@@ -459,7 +459,7 @@ static void AddItemToPlaylist( int i_media_id, bool bPlay, media_library_t* p_ml
                  i_media_id );
         return;
     }
-    playlist_t *p_playlist = pl_Get( p_ml );
+    playlist_t *p_playlist = THEPL;
     playlist_item_t *p_playlist_item = NULL;
 
     playlist_Lock( p_playlist );
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 8deaa98..1b7abe9 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -965,7 +965,7 @@ void PLModel::renameNode( QModelIndex index, QString name )
     if ( !index.isValid() ) index = rootIndex();
     input_item_t* p_input = this->getInputItem( index );
     input_item_SetName( p_input, qtu( name ) );
-    playlist_t *p_playlist = pl_Get( p_intf );
+    playlist_t *p_playlist = THEPL;
     input_item_WriteMeta( VLC_OBJECT(p_playlist), p_input );
     PL_UNLOCK;
 }
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index c2c0124..bce4002 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -987,7 +987,7 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
               im, setInput( input_thread_t * ) );
 
     /* initialize p_input (an input can already be running) */
-    p_input = playlist_CurrentInput( pl_Get(p_intf) );
+    p_input = playlist_CurrentInput( THEPL );
     if( p_input )
         emit inputChanged( p_input );
 
@@ -1055,7 +1055,7 @@ void MainInputManager::customEvent( QEvent *event )
 
     if( p_input != NULL )
         vlc_object_release( p_input );
-    p_input = playlist_CurrentInput( pl_Get(p_intf) );
+    p_input = playlist_CurrentInput( THEPL );
     emit inputChanged( p_input );
 }
 
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index d301094..a6e414f 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -334,7 +334,7 @@ static void Abort( void *obj )
 
 static void RegisterIntf( intf_thread_t *p_this )
 {
-    playlist_t *pl = pl_Get(p_this);
+    playlist_t *pl = p_this->p_sys->p_playlist;
     var_Create (pl, "qt4-iface", VLC_VAR_ADDRESS);
     var_SetAddress (pl, "qt4-iface", p_this);
     var_Create (pl, "window", VLC_VAR_STRING);
@@ -372,6 +372,12 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
     p_sys->p_mi = NULL;
     p_sys->pl_model = NULL;
 
+    /* set up the playlist to work on */
+    if( isDialogProvider )
+        p_intf->p_sys->p_playlist = pl_Get( (intf_thread_t *)p_intf->p_parent );
+    else
+        p_intf->p_sys->p_playlist = pl_Get( p_intf );
+
     /* */
     vlc_sem_init (&ready, 0);
 #ifdef Q_OS_MAC
@@ -420,7 +426,7 @@ static void Close( vlc_object_t *p_this )
 
     if( !p_sys->b_isDialogProvider )
     {
-        playlist_t *pl = pl_Get(p_intf);
+        playlist_t *pl = THEPL;
 
         var_Destroy (pl, "window");
         var_Destroy (pl, "qt4-iface");
diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp
index a07e083..5b27768 100644
--- a/modules/gui/qt4/qt4.hpp
+++ b/modules/gui/qt4/qt4.hpp
@@ -78,12 +78,13 @@ struct intf_sys_t
     int  i_screenHeight;     /* Detection of Small screens */
     unsigned voutWindowType; /* Type of vout_window_t provided */
     bool b_isDialogProvider; /* Qt mode or Skins mode */
+    playlist_t *p_playlist;  /* playlist */
 #ifdef _WIN32
     bool disable_volume_keys;
 #endif
 };
 
-#define THEPL pl_Get(p_intf)
+#define THEPL p_intf->p_sys->p_playlist
 #define QPL_LOCK playlist_Lock( THEPL );
 #define QPL_UNLOCK playlist_Unlock( THEPL );
 



More information about the vlc-commits mailing list