[vlc-commits] macosx: fixed potential race condition
Felix Paul Kühne
git at videolan.org
Mon Apr 16 20:25:12 CEST 2012
vlc/vlc-2.0 | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Apr 16 19:13:07 2012 +0200| [cc884078cea14b8781f2cba539f3837fe5356990] | committer: Felix Paul Kühne
macosx: fixed potential race condition
(cherry picked from commit 5b8a40579cfbacb736484f4210f1cc93e9caf440)
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.0.git/?a=commit;h=cc884078cea14b8781f2cba539f3837fe5356990
---
modules/gui/macosx/intf.m | 52 ++++++++++++++++++++++++--------------------
1 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 5a0d6df..816f2dd 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -778,6 +778,7 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_msg_arr removeAllObjects];
[o_msg_arr release];
+ o_msg_arr = NULL;
[o_msg_lock release];
@@ -2000,36 +2001,39 @@ unsigned int CocoaKeyToVLC( unichar i_key )
- (void)processReceivedlibvlcMessage:(const msg_item_t *) item ofType: (int)i_type withStr: (char *)str
{
- NSColor *o_white = [NSColor whiteColor];
- NSColor *o_red = [NSColor redColor];
- NSColor *o_yellow = [NSColor yellowColor];
- NSColor *o_gray = [NSColor grayColor];
- NSString * firstString, * secondString;
+ if (o_msg_arr)
+ {
+ NSColor *o_white = [NSColor whiteColor];
+ NSColor *o_red = [NSColor redColor];
+ NSColor *o_yellow = [NSColor yellowColor];
+ NSColor *o_gray = [NSColor grayColor];
+ NSString * firstString, * secondString;
- NSColor * pp_color[4] = { o_white, o_red, o_yellow, o_gray };
- static const char * ppsz_type[4] = { ": ", " error: ", " warning: ", " debug: " };
+ NSColor * pp_color[4] = { o_white, o_red, o_yellow, o_gray };
+ static const char * ppsz_type[4] = { ": ", " error: ", " warning: ", " debug: " };
- NSDictionary *o_attr;
- NSMutableAttributedString *o_msg_color;
+ NSDictionary *o_attr;
+ NSMutableAttributedString *o_msg_color;
- [o_msg_lock lock];
+ [o_msg_lock lock];
- if( [o_msg_arr count] + 2 > 600 )
- {
- [o_msg_arr removeObjectAtIndex: 0];
- [o_msg_arr removeObjectAtIndex: 1];
- }
- firstString = [NSString stringWithFormat:@"%s%s", item->psz_module, ppsz_type[i_type]];
- secondString = [NSString stringWithFormat:@"%@%s\n", firstString, str];
+ if( [o_msg_arr count] + 2 > 600 )
+ {
+ [o_msg_arr removeObjectAtIndex: 0];
+ [o_msg_arr removeObjectAtIndex: 1];
+ }
+ firstString = [NSString stringWithFormat:@"%s%s", item->psz_module, ppsz_type[i_type]];
+ secondString = [NSString stringWithFormat:@"%@%s\n", firstString, str];
- o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type] forKey: NSForegroundColorAttributeName];
- o_msg_color = [[NSMutableAttributedString alloc] initWithString: secondString attributes: o_attr];
- o_attr = [NSDictionary dictionaryWithObject: pp_color[3] forKey: NSForegroundColorAttributeName];
- [o_msg_color setAttributes: o_attr range: NSMakeRange( 0, [firstString length] )];
- [o_msg_arr addObject: [o_msg_color autorelease]];
+ o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type] forKey: NSForegroundColorAttributeName];
+ o_msg_color = [[NSMutableAttributedString alloc] initWithString: secondString attributes: o_attr];
+ o_attr = [NSDictionary dictionaryWithObject: pp_color[3] forKey: NSForegroundColorAttributeName];
+ [o_msg_color setAttributes: o_attr range: NSMakeRange( 0, [firstString length] )];
+ [o_msg_arr addObject: [o_msg_color autorelease]];
- b_msg_arr_changed = YES;
- [o_msg_lock unlock];
+ b_msg_arr_changed = YES;
+ [o_msg_lock unlock];
+ }
}
- (IBAction)saveDebugLog:(id)sender
More information about the vlc-commits
mailing list