Commit 8bfec18d authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

macosx: fix VLC object leaks

When building the menu's, autorelease the VLCAutoGeneratedMenu's instead of retaining. The NSMenuItem will do a retain/release for the live of the object in the NSMenuItem and thus once the menu's are done using the object, their retaincount will be 0 and they will be dealloc'ed at the end of the EventLoop. (An eventloop is One run of GUI updates you might say).
parent fcf777db
...@@ -710,13 +710,13 @@ ...@@ -710,13 +710,13 @@
case VLC_VAR_VOID: case VLC_VAR_VOID:
o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val ofType: i_type]; andValue: val ofType: i_type];
[o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]]; [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data autorelease]]];
break; break;
case VLC_VAR_BOOL: case VLC_VAR_BOOL:
o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: psz_variable ofObject: p_object
andValue: val ofType: i_type]; andValue: val ofType: i_type];
[o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]]; [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data autorelease]]];
if( !( i_type & VLC_VAR_ISCOMMAND ) ) if( !( i_type & VLC_VAR_ISCOMMAND ) )
[o_mi setState: val.b_bool ? TRUE : FALSE ]; [o_mi setState: val.b_bool ? TRUE : FALSE ];
break; break;
...@@ -821,7 +821,7 @@ ...@@ -821,7 +821,7 @@
o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""]; o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: strdup(psz_variable) ofObject: p_object o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: strdup(psz_variable) ofObject: p_object
andValue: another_val ofType: i_type]; andValue: another_val ofType: i_type];
[o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]]; [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data autorelease]]];
[o_lmi setTarget: self]; [o_lmi setTarget: self];
if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) ) if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
...@@ -836,10 +836,10 @@ ...@@ -836,10 +836,10 @@
[NSString stringWithFormat: @"%d", [NSString stringWithFormat: @"%d",
val_list.p_list->p_values[i].i_int]; val_list.p_list->p_values[i].i_int];
o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ]; o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: strdup(psz_variable) ofObject: p_object o_data = [[VLCAutoGeneratedMenuContent alloc] initWithVariableName: strdup(psz_variable) ofObject: p_object
andValue: val_list.p_list->p_values[i] ofType: i_type]; andValue: val_list.p_list->p_values[i] ofType: i_type];
[o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]]; [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data autorelease]]];
[o_lmi setTarget: self]; [o_lmi setTarget: self];
if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) ) if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
......
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