[vlc-devel] commit: Extensions/Qt: fix the deactivation race condition ( Jean-Philippe André )

git version control git at videolan.org
Thu Feb 4 02:01:07 CET 2010


vlc | branch: master | Jean-Philippe André <jpeg at videolan.org> | Wed Feb  3 23:56:32 2010 +0100| [547b2f41f76d9a502ada4e991ac56fb36e34dbd0] | committer: Jean-Philippe André 

Extensions/Qt: fix the deactivation race condition

Bind signal EDP::destroyed() to Dialog::deleteLater()
Clear p_sys_intf variable of the dialog
Signal condition when this is done

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

 modules/gui/qt4/dialogs/extensions.cpp |   18 +++++++++++++++---
 modules/gui/qt4/dialogs/extensions.hpp |    2 +-
 modules/gui/qt4/extensions_manager.cpp |    1 +
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/modules/gui/qt4/dialogs/extensions.cpp b/modules/gui/qt4/dialogs/extensions.cpp
index 829dc34..c2afd8b 100644
--- a/modules/gui/qt4/dialogs/extensions.cpp
+++ b/modules/gui/qt4/dialogs/extensions.cpp
@@ -60,6 +60,7 @@ ExtensionsDialogProvider::ExtensionsDialogProvider( intf_thread_t *_p_intf,
 
 ExtensionsDialogProvider::~ExtensionsDialogProvider()
 {
+    msg_Dbg( p_intf, "ExtensionsDialogProvider is quitting..." );
     var_DelCallback( p_intf, "dialog-extension", DialogCallback, NULL );
 }
 
@@ -87,6 +88,7 @@ int ExtensionsDialogProvider::DestroyExtDialog( extension_dialog_t *p_dialog )
         return VLC_EGENERIC;
     delete dialog;
     p_dialog->p_sys_intf = NULL;
+    vlc_cond_signal( &p_dialog->cond );
     return VLC_SUCCESS;
 }
 
@@ -172,6 +174,8 @@ ExtensionDialog::ExtensionDialog( intf_thread_t *_p_intf,
          , p_dialog( _p_dialog ), has_lock(false)
 {
     assert( p_dialog );
+    CONNECT( ExtensionsDialogProvider::getInstance(), destroyed(),
+             this, deleteLater() );
 
     msg_Dbg( p_intf, "Creating a new dialog: '%s'", p_dialog->psz_title );
 #if HAS_QT45
@@ -197,7 +201,11 @@ ExtensionDialog::ExtensionDialog( intf_thread_t *_p_intf,
 ExtensionDialog::~ExtensionDialog()
 {
     msg_Dbg( p_intf, "Deleting extension dialog '%s'", qtu(windowTitle()) );
+    /* Delete all widgets */
+    extension_widget_t *p_widget;
+    p_dialog->b_kill = true;
     p_dialog->p_sys_intf = NULL;
+    vlc_cond_signal( &p_dialog->cond );
 }
 
 QWidget* ExtensionDialog::CreateWidget( extension_widget_t *p_widget )
@@ -634,20 +642,24 @@ QWidget* ExtensionDialog::UpdateWidget( extension_widget_t *p_widget )
     }
 }
 
-void ExtensionDialog::DestroyWidget( extension_widget_t *p_widget )
+void ExtensionDialog::DestroyWidget( extension_widget_t *p_widget,
+                                     bool b_cond )
 {
     assert( p_widget && p_widget->b_kill );
     QWidget *widget = static_cast< QWidget* >( p_widget->p_sys_intf );
     delete widget;
     p_widget->p_sys_intf = NULL;
+    if( b_cond )
+        vlc_cond_signal( &p_dialog->cond );
 }
 
 /** Implement closeEvent() in order to intercept the event */
 void ExtensionDialog::closeEvent( QCloseEvent *event )
 {
     assert( p_dialog != NULL );
+    msg_Dbg( p_intf, "Dialog '%s' received a closeEvent",
+             p_dialog->psz_title );
     extension_DialogClosed( p_dialog );
-    event->accept();
-    emit destroyDialog( p_dialog );
+    p_dialog->p_sys_intf = NULL;
 }
 
diff --git a/modules/gui/qt4/dialogs/extensions.hpp b/modules/gui/qt4/dialogs/extensions.hpp
index cc8a32d..0313b46 100644
--- a/modules/gui/qt4/dialogs/extensions.hpp
+++ b/modules/gui/qt4/dialogs/extensions.hpp
@@ -103,7 +103,7 @@ private:
 
     QWidget *CreateWidget( extension_widget_t *p_widget );
     QWidget *UpdateWidget( extension_widget_t *p_widget );
-    void DestroyWidget( extension_widget_t *p_widget );
+    void DestroyWidget( extension_widget_t *p_widget, bool b_cond = true );
 
 protected:
     virtual void closeEvent( QCloseEvent* );
diff --git a/modules/gui/qt4/extensions_manager.cpp b/modules/gui/qt4/extensions_manager.cpp
index d8e03b1..653627c 100644
--- a/modules/gui/qt4/extensions_manager.cpp
+++ b/modules/gui/qt4/extensions_manager.cpp
@@ -55,6 +55,7 @@ ExtensionsManager::ExtensionsManager( intf_thread_t *_p_intf, QObject *parent )
 
 ExtensionsManager::~ExtensionsManager()
 {
+    ExtensionsDialogProvider::killInstance();
     if( p_extensions_manager )
     {
         module_unneed( p_extensions_manager, p_extensions_manager->p_module );




More information about the vlc-devel mailing list