From 73317f34563810a7b34bf3042fe9bf29e120c5c0 Mon Sep 17 00:00:00 2001 From: Pierre d'Herbemont Date: Sat, 3 Mar 2007 18:43:18 +0000 Subject: [PATCH] Mac OS X gui: Make sure libvlc exit properly. Don't forward the closeVout: if the interface is dead. --- modules/gui/macosx/intf.m | 31 +++++++++++++++++++++---------- modules/gui/macosx/voutgl.m | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index f1dae25977..552ffa3c41 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -105,6 +105,8 @@ void E_(CloseIntf) ( vlc_object_t *p_this ) /***************************************************************************** * Run: main loop *****************************************************************************/ +jmp_buf jmpbuffer; + static void Run( intf_thread_t *p_intf ) { /* Do it again - for some unknown reason, vlc_thread_create() often @@ -113,7 +115,11 @@ static void Run( intf_thread_t *p_intf ) vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_LOW ); [[VLCMain sharedInstance] setIntf: p_intf]; [NSBundle loadNibNamed: @"MainMenu" owner: NSApp]; - [NSApp run]; + + /* Install a jmpbuffer to where we can go back before the NSApp exit + * see applicationWillTerminate: */ + if(setjmp(jmpbuffer) == 0) + [NSApp run]; } int ExecuteOnMainThread( id target, SEL sel, void * p_arg ) @@ -1544,14 +1550,6 @@ static VLCMain *_o_sharedMainInstance = nil; vout_thread_t * p_vout; int returnedValue = 0; -#define p_input p_intf->p_sys->p_input - if( p_input ) - { - vlc_object_release( p_input ); - p_input = NULL; - } -#undef p_input - /* Stop playback */ p_playlist = pl_Yield( p_intf ); playlist_Stop( p_playlist ); @@ -1573,7 +1571,15 @@ static VLCMain *_o_sharedMainInstance = nil; p_intf->b_interaction = VLC_FALSE; var_DelCallback( p_intf, "interaction", InteractCallback, self ); - + +#define p_input p_intf->p_sys->p_input + if( p_input ) + { + vlc_object_release( p_input ); + p_input = NULL; + } +#undef p_input + /* remove global observer watching for vout device changes correctly */ [[NSNotificationCenter defaultCenter] removeObserver: self name: NSApplicationDidChangeScreenParametersNotification @@ -1646,8 +1652,13 @@ static VLCMain *_o_sharedMainInstance = nil; [[NSUserDefaults standardUserDefaults] synchronize]; p_intf->b_die = VLC_TRUE; + + /* Go back to Run() and make libvlc exit properly */ + longjmp( jmpbuffer, 1 ); + /* not reached */ } + - (IBAction)clearRecentItems:(id)sender { [[NSDocumentController sharedDocumentController] diff --git a/modules/gui/macosx/voutgl.m b/modules/gui/macosx/voutgl.m index c3b3da19d6..7a0273b1e9 100644 --- a/modules/gui/macosx/voutgl.m +++ b/modules/gui/macosx/voutgl.m @@ -200,7 +200,7 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this ) { aglDestroyContext(p_vout->p_sys->agl_ctx); } - else + else if(!VLCIntf->b_die) { NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; -- 2.39.5