[vlc-devel] commit: Qt4: use explicit direct connections when passing VLC pointers... ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Mar 1 20:08:49 CET 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Mar  1 21:06:10 2010 +0200| [88d39ceef6b983663ccae410be55a2ace26d9074] | committer: Rémi Denis-Courmont 

Qt4: use explicit direct connections when passing VLC pointers...

...without reference. With a direct connection, the call stack ensures
that the pointer remains valid until the slot returns. This is not the
case for asynchronous ("queued" in Qt4 documentation) signals.

Obviously, this means we have to emit the signals from the Qt4 main loop
thread, *or* alternatively not touch any Qt4 UI stuff fromt he slot.
Hopefully, any such bug would be easier to find this ways.

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

 modules/gui/qt4/components/controller.cpp          |    4 ++--
 modules/gui/qt4/components/interface_widgets.cpp   |    4 ++--
 modules/gui/qt4/components/playlist/playlist.cpp   |    4 ++--
 .../gui/qt4/components/playlist/playlist_model.cpp |    8 ++++----
 modules/gui/qt4/components/playlist/selector.cpp   |    4 ++--
 .../gui/qt4/components/playlist/standardpanel.cpp  |    4 ++--
 modules/gui/qt4/dialogs/mediainfo.cpp              |   16 ++++++++--------
 modules/gui/qt4/extensions_manager.cpp             |    4 ++--
 modules/gui/qt4/input_manager.cpp                  |    4 ++--
 modules/gui/qt4/qt4.hpp                            |    5 ++++-
 10 files changed, 30 insertions(+), 27 deletions(-)

diff --git a/modules/gui/qt4/components/controller.cpp b/modules/gui/qt4/components/controller.cpp
index 02866ff..a0cfc94 100644
--- a/modules/gui/qt4/components/controller.cpp
+++ b/modules/gui/qt4/components/controller.cpp
@@ -682,8 +682,8 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i, QWi
 
     vlc_mutex_init_recursive( &lock );
 
-    CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
-             this, setVoutList( vout_thread_t **, int ) );
+    DCONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
+              this, setVoutList( vout_thread_t **, int ) );
 
     /* First Move */
     QRect rect1 = getSettings()->value( "FullScreen/screen" ).toRect();
diff --git a/modules/gui/qt4/components/interface_widgets.cpp b/modules/gui/qt4/components/interface_widgets.cpp
index f700eb1..ba5b4a5 100644
--- a/modules/gui/qt4/components/interface_widgets.cpp
+++ b/modules/gui/qt4/components/interface_widgets.cpp
@@ -429,8 +429,8 @@ SpeedLabel::SpeedLabel( intf_thread_t *_p_intf, const QString& text,
     /* Change the SpeedRate in the Status Bar */
     CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
 
-    CONNECT( THEMIM, inputChanged( input_thread_t * ),
-             speedControl, activateOnState() );
+    DCONNECT( THEMIM, inputChanged( input_thread_t * ),
+              speedControl, activateOnState() );
 }
 
 SpeedLabel::~SpeedLabel()
diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 87e8c3d..2d3ab03 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -96,8 +96,8 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
     rightPanel = new StandardPLPanel( this, p_intf, THEPL, p_root );
 
     /* Connect the activation of the selector to a redefining of the PL */
-    CONNECT( selector, activated( playlist_item_t * ),
-             rightPanel, setRoot( playlist_item_t * ) );
+    DCONNECT( selector, activated( playlist_item_t * ),
+              rightPanel, setRoot( playlist_item_t * ) );
 
     rightPanel->setRoot( p_root );
 
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index ebf78d7..3f14247 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -89,10 +89,10 @@ PLModel::PLModel( playlist_t *_p_playlist,  /* THEPL */
 #undef ADD_ICON
 
     rebuild( p_root );
-    CONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
-            this, processInputItemUpdate( input_item_t *) );
-    CONNECT( THEMIM, inputChanged( input_thread_t * ),
-            this, processInputItemUpdate( input_thread_t* ) );
+    DCONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
+             this, processInputItemUpdate( input_item_t *) );
+    DCONNECT( THEMIM, inputChanged( input_thread_t * ),
+             this, processInputItemUpdate( input_thread_t* ) );
     CONNECT( THEMIM, playlistItemAppended( int, int ),
              this, processItemAppend( int, int ) );
     CONNECT( THEMIM, playlistItemRemoved( int ),
diff --git a/modules/gui/qt4/components/playlist/selector.cpp b/modules/gui/qt4/components/playlist/selector.cpp
index 2b42401..2e61680 100644
--- a/modules/gui/qt4/components/playlist/selector.cpp
+++ b/modules/gui/qt4/components/playlist/selector.cpp
@@ -132,8 +132,8 @@ PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf )
              this, plItemAdded( int, int ) );
     CONNECT( THEMIM, playlistItemRemoved( int ),
              this, plItemRemoved( int ) );
-    CONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
-            this, inputItemUpdate( input_item_t * ) );
+    DCONNECT( THEMIM->getIM(), metaChanged( input_item_t *),
+              this, inputItemUpdate( input_item_t * ) );
 
     createItems();
     CONNECT( this, itemActivated( QTreeWidgetItem *, int ),
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index fbf38e3..a508cb8 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -123,8 +123,8 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
 
     getSettings()->endGroup();
 
-    CONNECT( THEMIM, leafBecameParent( input_item_t *),
-             this, browseInto( input_item_t * ) );
+    DCONNECT( THEMIM, leafBecameParent( input_item_t *),
+              this, browseInto( input_item_t * ) );
 
     CONNECT( model, currentChanged( const QModelIndex& ),
              this, handleExpansion( const QModelIndex& ) );
diff --git a/modules/gui/qt4/dialogs/mediainfo.cpp b/modules/gui/qt4/dialogs/mediainfo.cpp
index 51e991a..930c9d4 100644
--- a/modules/gui/qt4/dialogs/mediainfo.cpp
+++ b/modules/gui/qt4/dialogs/mediainfo.cpp
@@ -100,14 +100,14 @@ MediaInfoDialog::MediaInfoDialog( intf_thread_t *_p_intf,
          * Connects on the various signals of input_Manager
          * For the currently playing element
          **/
-        CONNECT( THEMIM->getIM(), infoChanged( input_item_t* ),
-                 IP, update( input_item_t* ) );
-        CONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ),
-                 MP, update( input_item_t* ) );
-        CONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ),
-                 EMP, update( input_item_t* ) );
-        CONNECT( THEMIM->getIM(), statisticsUpdated( input_item_t* ),
-                 ISP, update( input_item_t* ) );
+        DCONNECT( THEMIM->getIM(), infoChanged( input_item_t* ),
+                  IP, update( input_item_t* ) );
+        DCONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ),
+                  MP, update( input_item_t* ) );
+        DCONNECT( THEMIM->getIM(), currentMetaChanged( input_item_t* ),
+                  EMP, update( input_item_t* ) );
+        DCONNECT( THEMIM->getIM(), statisticsUpdated( input_item_t* ),
+                  ISP, update( input_item_t* ) );
 
         if( THEMIM->getInput() )
             p_item = input_GetItem( THEMIM->getInput() );
diff --git a/modules/gui/qt4/extensions_manager.cpp b/modules/gui/qt4/extensions_manager.cpp
index 236138d..b40d7fd 100644
--- a/modules/gui/qt4/extensions_manager.cpp
+++ b/modules/gui/qt4/extensions_manager.cpp
@@ -48,8 +48,8 @@ ExtensionsManager::ExtensionsManager( intf_thread_t *_p_intf, QObject *parent )
     menuMapper = new QSignalMapper( this );
     CONNECT( menuMapper, mapped( int ), this, triggerMenu( int ) );
     CONNECT( THEMIM->getIM(), statusChanged( int ), this, playingChanged( int ) );
-    CONNECT( THEMIM, inputChanged( input_thread_t* ),
-             this, inputChanged( input_thread_t* ) );
+    DCONNECT( THEMIM, inputChanged( input_thread_t* ),
+              this, inputChanged( input_thread_t* ) );
     b_unloading = false;
     b_failed = false;
 }
diff --git a/modules/gui/qt4/input_manager.cpp b/modules/gui/qt4/input_manager.cpp
index 4edfc82..a648feb 100644
--- a/modules/gui/qt4/input_manager.cpp
+++ b/modules/gui/qt4/input_manager.cpp
@@ -918,8 +918,8 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
     var_AddCallback( THEPL, "volume-muted", SoundMuteChanged, this );
 
     /* Warn our embedded IM about input changes */
-    CONNECT( this, inputChanged( input_thread_t * ),
-             im, setInput( input_thread_t * ) );
+    DCONNECT( this, inputChanged( input_thread_t * ),
+              im, setInput( input_thread_t * ) );
 
     /* emit check if playlist has already started playing */
     input_thread_t *p_input = playlist_CurrentInput( THEPL );
diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp
index 15f8a3a..9111839 100644
--- a/modules/gui/qt4/qt4.hpp
+++ b/modules/gui/qt4/qt4.hpp
@@ -94,7 +94,10 @@ struct intf_sys_t
 #define qtr( i ) QString::fromUtf8( vlc_gettext(i) )
 #define qtu( i ) ((i).toUtf8().constData())
 
-#define CONNECT( a, b, c, d ) connect( a, SIGNAL( b ), c, SLOT(d) )
+#define CONNECT( a, b, c, d ) \
+        connect( a, SIGNAL( b ), c, SLOT(d) )
+#define DCONNECT( a, b, c, d ) \
+        connect( a, SIGNAL( b ), c, SLOT(d), Qt::DirectConnection )
 #define BUTTONACT( b, a ) connect( b, SIGNAL( clicked() ), this, SLOT(a) )
 
 #define BUTTON_SET( button, text, tooltip )  \




More information about the vlc-devel mailing list