From 8969b155735b1659a57da6da33710df8e82c6352 Mon Sep 17 00:00:00 2001 From: Eric Petit Date: Thu, 19 May 2005 14:11:30 +0000 Subject: [PATCH] macosx/vout*: quick kludge for Tiger crashes Use performSelectorOnMainThread when available (>= 10.2) to create the window from the main thread. Also fixed a couple warnings --- modules/gui/macosx/vout.h | 6 ++++-- modules/gui/macosx/vout.m | 31 ++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/modules/gui/macosx/vout.h b/modules/gui/macosx/vout.h index b475efbaa6..e2babf1bf6 100644 --- a/modules/gui/macosx/vout.h +++ b/modules/gui/macosx/vout.h @@ -34,10 +34,12 @@ Ptr p_fullscreen_state; mtime_t i_time_mouse_last_moved; + NSRect * s_frame; + vlc_bool_t b_init_ok; } -- (id)initWithVout:(vout_thread_t *)_p_vout - frame:(NSRect *)s_frame; +- (id) initWithVout: (vout_thread_t *) p_vout frame: (NSRect *) s_frame; +- (id) initReal: (id) sender; - (void)close; - (void)setOnTop:(BOOL)b_on_top; diff --git a/modules/gui/macosx/vout.m b/modules/gui/macosx/vout.m index 33501d1e18..9bfc0075f6 100644 --- a/modules/gui/macosx/vout.m +++ b/modules/gui/macosx/vout.m @@ -65,7 +65,30 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, *****************************************************************************/ @implementation VLCWindow -- (id)initWithVout:(vout_thread_t *)_p_vout frame:(NSRect *)s_frame +- (id) initWithVout: (vout_thread_t *) vout frame: (NSRect *) frame +{ + p_vout = vout; + s_frame = frame; + + if( MACOS_VERSION >= 10.2 ) + { + [self performSelectorOnMainThread: @selector(initReal:) + withObject: NULL waitUntilDone: YES]; + } + else + { + [self initReal: NULL]; + } + + if( !b_init_ok ) + { + return NULL; + } + + return self; +} + +- (id) initReal: (id) sender { NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init]; NSArray *o_screens = [NSScreen screens]; @@ -74,7 +97,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, int i_timeout, i_device; vlc_value_t value_drawable; - p_vout = _p_vout; + b_init_ok = VLC_FALSE; var_Get( p_vout->p_vlc, "drawable", &value_drawable ); @@ -261,6 +284,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, [self makeFirstResponder: self]; [o_pool release]; + + b_init_ok = VLC_TRUE; return self; } @@ -455,7 +480,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, - (void)updateTitle { - NSMutableString * o_title,* o_mrl; + NSMutableString * o_title = NULL, * o_mrl = NULL; input_thread_t * p_input; if( p_vout == NULL ) -- 2.39.2