Commit ebec8934 authored by Ilkka Ollakka's avatar 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
parent 984fb14a
......@@ -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 )
......
......@@ -164,7 +164,6 @@ public slots:
private slots:
void debug();
void updateOnTimer();
void doComponentsUpdate();
void setStatus( int );
void setRate( int );
......
......@@ -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;
}
......
......@@ -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
{
......
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