[vlc-devel] commit: Allow thread-cancelation in qt4-module, and define cancelation function (Ilkka Ollakka )
git version control
git at videolan.org
Thu Oct 16 14:19:11 CEST 2008
vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Thu Oct 16 15:15:33 2008 +0300| [ebec8934044432bbe1574e8531b39a5038eeb9b7] | committer: Ilkka Ollakka
Allow thread-cancelation in qt4-module, and define cancelation function
Cancelation function emits event to main-interface to shut down. Thanks to
courmisch for pointing out this possibility.
Should be final issue on ticket #1365 and this commit should fix it
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ebec8934044432bbe1574e8531b39a5038eeb9b7
---
modules/gui/qt4/main_interface.cpp | 20 +++++---------------
modules/gui/qt4/main_interface.hpp | 1 -
modules/gui/qt4/qt4.cpp | 14 ++++++++++++--
modules/gui/qt4/qt4.hpp | 2 ++
4 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp
index 943c6dd..7836abd 100644
--- a/modules/gui/qt4/main_interface.cpp
+++ b/modules/gui/qt4/main_interface.cpp
@@ -186,11 +186,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* END CONNECTS ON IM */
- /** OnTimeOut **/
- /* TODO Remove this function, but so far, there is no choice because there
- is no intf-should-die variable #1365 */
- ON_TIMEOUT( updateOnTimer() );
-
/************
* Callbacks
************/
@@ -876,16 +871,6 @@ void MainInterface::setRate( int rate )
speedControl->updateControls( rate );
}
-void MainInterface::updateOnTimer()
-{
- /* No event for dying */
- if( !vlc_object_alive( p_intf ) )
- {
- QApplication::closeAllWindows();
- QApplication::quit();
- }
-}
-
/*****************************************************************************
* Systray Icon and Systray Menu
*****************************************************************************/
@@ -1103,6 +1088,11 @@ void MainInterface::customEvent( QEvent *event )
setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
show(); /* necessary to apply window flags?? */
}
+ if ( event->type() == MainInterfaceClose_Type )
+ {
+ QApplication::closeAllWindows();
+ QApplication::quit();
+ }
}
void MainInterface::keyPressEvent( QKeyEvent *e )
diff --git a/modules/gui/qt4/main_interface.hpp b/modules/gui/qt4/main_interface.hpp
index 111979f..8be4405 100644
--- a/modules/gui/qt4/main_interface.hpp
+++ b/modules/gui/qt4/main_interface.hpp
@@ -164,7 +164,6 @@ public slots:
private slots:
void debug();
- void updateOnTimer();
void doComponentsUpdate();
void setStatus( int );
void setRate( int );
diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp
index ac00b62..84a4934 100755
--- a/modules/gui/qt4/qt4.cpp
+++ b/modules/gui/qt4/qt4.cpp
@@ -315,15 +315,20 @@ static void Run( intf_thread_t *p_intf )
}
else
{
- int canc = vlc_savecancel ();
Init( VLC_OBJECT(p_intf) );
- vlc_restorecancel( canc );
}
}
static QMutex windowLock;
static QWaitCondition windowWait;
+static void ThreadCleanup( void *param)
+{
+ intf_thread_t *p_intf = (intf_thread_t *)param;
+ QEvent *event = new QEvent((QEvent::Type)(MainInterfaceClose_Type) );
+ QApplication::postEvent( p_intf->p_sys->p_mi, event );
+}
+
static void *Init( vlc_object_t *obj )
{
intf_thread_t *p_intf = (intf_thread_t *)obj;
@@ -333,6 +338,8 @@ static void *Init( vlc_object_t *obj )
int argc = 1;
int canc = vlc_savecancel ();
+ msg_Dbg( p_intf, "Setting ThreadCleanup");
+ vlc_cleanup_push( ThreadCleanup, (void*)p_intf );
Q_INIT_RESOURCE( vlc );
#if !defined(WIN32) && !defined(__APPLE__)
@@ -447,10 +454,12 @@ static void *Init( vlc_object_t *obj )
p_intf->p_sys->psz_filepath = EMPTY_STR( psz_path ) ? config_GetHomeDir()
: psz_path;
+ vlc_restorecancel (canc);
/* Launch */
app->exec();
/* And quit */
+ canc = vlc_savecancel ();
msg_Dbg( p_intf, "Quitting the Qt4 Interface" );
if (miP)
@@ -490,6 +499,7 @@ static void *Init( vlc_object_t *obj )
config_PutPsz( p_intf, "qt-filedialog-path", p_intf->p_sys->psz_filepath );
free( psz_path );
vlc_restorecancel (canc);
+ vlc_cleanup_pop();
return NULL;
}
diff --git a/modules/gui/qt4/qt4.hpp b/modules/gui/qt4/qt4.hpp
index f9a4663..7a75028 100755
--- a/modules/gui/qt4/qt4.hpp
+++ b/modules/gui/qt4/qt4.hpp
@@ -48,6 +48,7 @@ class DialogsProvider;
class VideoWidget;
class QSettings;
+
#if defined(Q_WS_WIN)
#include <QApplication>
@@ -158,6 +159,7 @@ static const int DialogEvent_Type = QEvent::User + DialogEventType + 1;
//static const int PLUndockEvent_Type = QEvent::User + DialogEventType + 2;
//static const int PLDockEvent_Type = QEvent::User + DialogEventType + 3;
static const int SetVideoOnTopEvent_Type = QEvent::User + DialogEventType + 4;
+static const int MainInterfaceClose_Type = QEvent::User + 404;
class DialogEvent : public QEvent
{
More information about the vlc-devel
mailing list