[vlc-devel] [PATCH 4/6] qt4: Move Qt4 interface cleanup to aboutToQuit() signal

Juho Vähä-Herttua juhovh at iki.fi
Sat Jul 24 23:50:07 CEST 2010


On 24.7.2010, at 23.57, Rémi Denis-Courmont wrote:
> Le samedi 24 juillet 2010 23:31:12 Juho Vähä-Herttua, vous avez écrit :
>> ---
>> 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();
>> 
> 
> Currently, there does seem to be a race at exit between the interface thread 
> and the vout provider cleaning up. I am afraid this will makes our like even 
> more miserable when trying to fix it.

Ok, actually I'm ok with not merging this patch at all. At first I thought it would be very useful but later I noticed it's not really necessary. It was mostly based on the Qt documentation:

"We recommend that you connect clean-up code to the aboutToQuit() signal, instead of putting it in your application's main() function. This is because, on some platforms the QApplication::exec() call may not return. For example, on the Windows platform, when the user logs off, the system terminates the process after Qt closes all top-level windows. Hence, there is no guarantee that the application will have time to exit its event loop and execute code at the end of the main() function, after the QApplication::exec() call."


Juho

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4215 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100725/c82c4084/attachment.bin>


More information about the vlc-devel mailing list