Commit 547b2f41 authored by Jean-Philippe André's avatar 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
parent 13ca60ed
...@@ -60,6 +60,7 @@ ExtensionsDialogProvider::ExtensionsDialogProvider( intf_thread_t *_p_intf, ...@@ -60,6 +60,7 @@ ExtensionsDialogProvider::ExtensionsDialogProvider( intf_thread_t *_p_intf,
ExtensionsDialogProvider::~ExtensionsDialogProvider() ExtensionsDialogProvider::~ExtensionsDialogProvider()
{ {
msg_Dbg( p_intf, "ExtensionsDialogProvider is quitting..." );
var_DelCallback( p_intf, "dialog-extension", DialogCallback, NULL ); var_DelCallback( p_intf, "dialog-extension", DialogCallback, NULL );
} }
...@@ -87,6 +88,7 @@ int ExtensionsDialogProvider::DestroyExtDialog( extension_dialog_t *p_dialog ) ...@@ -87,6 +88,7 @@ int ExtensionsDialogProvider::DestroyExtDialog( extension_dialog_t *p_dialog )
return VLC_EGENERIC; return VLC_EGENERIC;
delete dialog; delete dialog;
p_dialog->p_sys_intf = NULL; p_dialog->p_sys_intf = NULL;
vlc_cond_signal( &p_dialog->cond );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -172,6 +174,8 @@ ExtensionDialog::ExtensionDialog( intf_thread_t *_p_intf, ...@@ -172,6 +174,8 @@ ExtensionDialog::ExtensionDialog( intf_thread_t *_p_intf,
, p_dialog( _p_dialog ), has_lock(false) , p_dialog( _p_dialog ), has_lock(false)
{ {
assert( p_dialog ); assert( p_dialog );
CONNECT( ExtensionsDialogProvider::getInstance(), destroyed(),
this, deleteLater() );
msg_Dbg( p_intf, "Creating a new dialog: '%s'", p_dialog->psz_title ); msg_Dbg( p_intf, "Creating a new dialog: '%s'", p_dialog->psz_title );
#if HAS_QT45 #if HAS_QT45
...@@ -197,7 +201,11 @@ ExtensionDialog::ExtensionDialog( intf_thread_t *_p_intf, ...@@ -197,7 +201,11 @@ ExtensionDialog::ExtensionDialog( intf_thread_t *_p_intf,
ExtensionDialog::~ExtensionDialog() ExtensionDialog::~ExtensionDialog()
{ {
msg_Dbg( p_intf, "Deleting extension dialog '%s'", qtu(windowTitle()) ); 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; p_dialog->p_sys_intf = NULL;
vlc_cond_signal( &p_dialog->cond );
} }
QWidget* ExtensionDialog::CreateWidget( extension_widget_t *p_widget ) QWidget* ExtensionDialog::CreateWidget( extension_widget_t *p_widget )
...@@ -634,20 +642,24 @@ QWidget* ExtensionDialog::UpdateWidget( 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 ); assert( p_widget && p_widget->b_kill );
QWidget *widget = static_cast< QWidget* >( p_widget->p_sys_intf ); QWidget *widget = static_cast< QWidget* >( p_widget->p_sys_intf );
delete widget; delete widget;
p_widget->p_sys_intf = NULL; p_widget->p_sys_intf = NULL;
if( b_cond )
vlc_cond_signal( &p_dialog->cond );
} }
/** Implement closeEvent() in order to intercept the event */ /** Implement closeEvent() in order to intercept the event */
void ExtensionDialog::closeEvent( QCloseEvent *event ) void ExtensionDialog::closeEvent( QCloseEvent *event )
{ {
assert( p_dialog != NULL ); assert( p_dialog != NULL );
msg_Dbg( p_intf, "Dialog '%s' received a closeEvent",
p_dialog->psz_title );
extension_DialogClosed( p_dialog ); extension_DialogClosed( p_dialog );
event->accept(); p_dialog->p_sys_intf = NULL;
emit destroyDialog( p_dialog );
} }
...@@ -103,7 +103,7 @@ private: ...@@ -103,7 +103,7 @@ private:
QWidget *CreateWidget( extension_widget_t *p_widget ); QWidget *CreateWidget( extension_widget_t *p_widget );
QWidget *UpdateWidget( 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: protected:
virtual void closeEvent( QCloseEvent* ); virtual void closeEvent( QCloseEvent* );
......
...@@ -55,6 +55,7 @@ ExtensionsManager::ExtensionsManager( intf_thread_t *_p_intf, QObject *parent ) ...@@ -55,6 +55,7 @@ ExtensionsManager::ExtensionsManager( intf_thread_t *_p_intf, QObject *parent )
ExtensionsManager::~ExtensionsManager() ExtensionsManager::~ExtensionsManager()
{ {
ExtensionsDialogProvider::killInstance();
if( p_extensions_manager ) if( p_extensions_manager )
{ {
module_unneed( p_extensions_manager, p_extensions_manager->p_module ); module_unneed( p_extensions_manager, p_extensions_manager->p_module );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment