Commit ca5043b4 authored by Rémi Duraffort's avatar Rémi Duraffort

macosx: fix memleak in bookmarks dialog.

parent 0e8641f3
...@@ -158,28 +158,22 @@ static VLCBookmarks *_o_sharedInstance = nil; ...@@ -158,28 +158,22 @@ static VLCBookmarks *_o_sharedInstance = nil;
int row; int row;
row = [o_tbl_dataTable selectedRow]; row = [o_tbl_dataTable selectedRow];
if( !p_input ) if( !p_input && row < 0 )
{
return; return;
}
else if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks, if( input_Control( p_input, INPUT_GET_BOOKMARKS, &pp_bookmarks,
&i_bookmarks ) != VLC_SUCCESS ) &i_bookmarks ) != VLC_SUCCESS )
{ {
vlc_object_release( p_input ); vlc_object_release( p_input );
return; return;
} }
else if(row < 0)
{ [o_edit_fld_name setStringValue: [NSString stringWithUTF8String:
vlc_object_release( p_input );
return;
} else {
[o_edit_fld_name setStringValue: [NSString stringWithUTF8String:
pp_bookmarks[row]->psz_name]]; pp_bookmarks[row]->psz_name]];
[o_edit_fld_time setStringValue: [[NSNumber numberWithInt: [o_edit_fld_time setStringValue: [[NSNumber numberWithInt:
(pp_bookmarks[row]->i_time_offset / 1000000)] stringValue]]; (pp_bookmarks[row]->i_time_offset / 1000000)] stringValue]];
[o_edit_fld_bytes setStringValue: [[NSNumber numberWithInt: [o_edit_fld_bytes setStringValue: [[NSNumber numberWithInt:
pp_bookmarks[row]->i_byte_offset] stringValue]]; pp_bookmarks[row]->i_byte_offset] stringValue]];
}
/* Just keep the pointer value to check if it /* Just keep the pointer value to check if it
* changes. Note, we don't need to keep a reference to the object. * changes. Note, we don't need to keep a reference to the object.
...@@ -192,6 +186,12 @@ static VLCBookmarks *_o_sharedInstance = nil; ...@@ -192,6 +186,12 @@ static VLCBookmarks *_o_sharedInstance = nil;
modalDelegate: o_edit_window modalDelegate: o_edit_window
didEndSelector: nil didEndSelector: nil
contextInfo: nil]; contextInfo: nil];
// Clear the bookmark list
for( int i = 0; i < i_bookmarks; i++)
vlc_seekpoint_Delete( pp_bookmarks[i] );
free( pp_bookmarks );
} }
- (IBAction)edit_cancel:(id)sender - (IBAction)edit_cancel:(id)sender
...@@ -246,8 +246,7 @@ static VLCBookmarks *_o_sharedInstance = nil; ...@@ -246,8 +246,7 @@ static VLCBookmarks *_o_sharedInstance = nil;
!= VLC_SUCCESS ) != VLC_SUCCESS )
{ {
msg_Warn( VLCIntf, "Unable to change the bookmark"); msg_Warn( VLCIntf, "Unable to change the bookmark");
vlc_object_release( p_input ); goto clear;
return;
} }
[o_tbl_dataTable reloadData]; [o_tbl_dataTable reloadData];
...@@ -256,6 +255,12 @@ static VLCBookmarks *_o_sharedInstance = nil; ...@@ -256,6 +255,12 @@ static VLCBookmarks *_o_sharedInstance = nil;
[NSApp endSheet: o_edit_window]; [NSApp endSheet: o_edit_window];
[o_edit_window close]; [o_edit_window close];
clear:
// Clear the bookmark list
for( int i = 0; i < i_bookmarks; i++)
vlc_seekpoint_Delete( pp_bookmarks[i] );
free( pp_bookmarks );
} }
- (IBAction)extract:(id)sender - (IBAction)extract:(id)sender
...@@ -322,6 +327,11 @@ static VLCBookmarks *_o_sharedInstance = nil; ...@@ -322,6 +327,11 @@ static VLCBookmarks *_o_sharedInstance = nil;
free( psz_uri ); free( psz_uri );
vlc_object_release( p_input ); vlc_object_release( p_input );
msg_Dbg( VLCIntf, "released input"); msg_Dbg( VLCIntf, "released input");
// Clear the bookmark list
for( int i = 0; i < i_bookmarks; i++)
vlc_seekpoint_Delete( pp_bookmarks[i] );
free( pp_bookmarks );
} }
- (IBAction)goToBookmark:(id)sender - (IBAction)goToBookmark:(id)sender
...@@ -381,6 +391,10 @@ static VLCBookmarks *_o_sharedInstance = nil; ...@@ -381,6 +391,10 @@ static VLCBookmarks *_o_sharedInstance = nil;
} }
else { else {
vlc_object_release( p_input ); vlc_object_release( p_input );
// Clear the bookmark list
for( int i = 0; i < i_bookmarks; i++)
vlc_seekpoint_Delete( pp_bookmarks[i] );
free( pp_bookmarks );
return i_bookmarks; return i_bookmarks;
} }
} }
...@@ -428,6 +442,11 @@ static VLCBookmarks *_o_sharedInstance = nil; ...@@ -428,6 +442,11 @@ static VLCBookmarks *_o_sharedInstance = nil;
UTF8String] ); UTF8String] );
ret = @"unknown identifier"; ret = @"unknown identifier";
} }
// Clear the bookmark list
for( int i = 0; i < i_bookmarks; i++)
vlc_seekpoint_Delete( pp_bookmarks[i] );
free( pp_bookmarks );
} }
vlc_object_release( p_input ); vlc_object_release( p_input );
return ret; return ret;
......
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