[vlc-devel] [PATCH 4/6] qt4: Move Qt4 interface cleanup to aboutToQuit() signal
Juho Vähä-Herttua
juhovh at iki.fi
Sat Jul 24 22:31:12 CEST 2010
---
modules/gui/qt4/qt4.cpp | 16 +++++++++++++---
modules/gui/qt4/util/qvlcapp.hpp | 19 +++++++++++++++++++
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index 676a82b..05ef8b8 100644
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -62,6 +62,7 @@ static void Close ( vlc_object_t * );
static int WindowOpen ( vlc_object_t * );
static void WindowClose ( vlc_object_t * );
static void *Thread ( void * );
+static void Cleanup ( void * );
static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
/*****************************************************************************
@@ -406,6 +407,7 @@ static void *Thread( void *obj )
#endif
QVLCApp app( argc, argv );
+ app.registerCleanup( Cleanup, p_intf );
p_intf->p_sys->p_app = &app;
@@ -476,6 +478,17 @@ static void *Thread( void *obj )
/* Launch */
app.exec();
+ /* Delete the application automatically */
+ return NULL;
+}
+
+static void Cleanup( void *obj )
+{
+ intf_thread_t *p_intf = (intf_thread_t *)obj;
+ MainInterface *p_mi = p_intf->p_sys->p_mi;
+
+ msg_Dbg( p_intf, "Cleaning up the interface" );
+
/* And quit */
QApplication::closeAllWindows();
@@ -509,9 +522,6 @@ static void *Thread( void *obj )
/* Destroy the MainInputManager */
MainInputManager::killInstance();
-
- /* Delete the application automatically */
- return NULL;
}
/*****************************************************************************
diff --git a/modules/gui/qt4/util/qvlcapp.hpp b/modules/gui/qt4/util/qvlcapp.hpp
index bfd8a90..424c504 100644
--- a/modules/gui/qt4/util/qvlcapp.hpp
+++ b/modules/gui/qt4/util/qvlcapp.hpp
@@ -43,9 +43,16 @@ class QVLCApp : public QApplication
public:
QVLCApp( int & argc, char ** argv ) : QApplication( argc, argv, true )
{
+ connect( this, SIGNAL(aboutToQuit()), this, SLOT(cleanup()) );
connect( this, SIGNAL(quitSignal()), this, SLOT(quit()) );
}
+ void registerCleanup( void (*p_cleanup)( void * ), void *obj )
+ {
+ cleanupFunc = p_cleanup;
+ cleanupParam = obj;
+ }
+
static void triggerQuit()
{
QVLCApp *app = qobject_cast<QVLCApp*>( instance() );
@@ -61,9 +68,21 @@ public:
}
#endif
+public slots:
+ void cleanup()
+ {
+ if( cleanupFunc != NULL )
+ {
+ cleanupFunc( cleanupParam );
+ }
+ }
+
signals:
void quitSignal();
+private:
+ void (*cleanupFunc)( void * );
+ void *cleanupParam;
};
#endif
--
1.6.5.7
More information about the vlc-devel
mailing list