[vlc-devel] commit: macosx: vlc object leaking: (Derk-Jan Hartman )
git version control
git at videolan.org
Fri Apr 3 15:00:50 CEST 2009
vlc | branch: master | Derk-Jan Hartman <hartman at videolan.org> | Fri Apr 3 14:58:43 2009 +0200| [1aeb56fa49c58ecfd1724096f1e8d74bfe0573c6] | committer: Derk-Jan Hartman
macosx: vlc object leaking:
NSMenuItems still exist when libvlc_Quit is called, and thus some items are likely not autoreleased before vlc quits. Set all representedObjects for all menu's to null so that the menuitems no longer retain any of the vlc objects.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1aeb56fa49c58ecfd1724096f1e8d74bfe0573c6
---
modules/gui/macosx/intf.m | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 335ada7..833dee4 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -700,6 +700,19 @@ static VLCMain *_o_sharedMainInstance = nil;
#pragma mark -
#pragma mark Termination
+- (void)releaseRepresentedObjects:(NSMenu *)the_menu
+{
+ NSArray *menuitems_array = [the_menu itemArray];
+ for( int i=0; i<[menuitems_array count]; i++ )
+ {
+ NSMenuItem *one_item = [menuitems_array objectAtIndex: i];
+ if( [one_item hasSubmenu] )
+ [self releaseRepresentedObjects: [one_item submenu]];
+
+ [one_item setRepresentedObject:NULL];
+ }
+}
+
- (void)applicationWillTerminate:(NSNotification *)notification
{
playlist_t * p_playlist;
@@ -794,6 +807,9 @@ static VLCMain *_o_sharedMainInstance = nil;
/* write cached user defaults to disk */
[[NSUserDefaults standardUserDefaults] synchronize];
+ /* Make sure the Menu doesn't have any references to vlc objects anymore */
+ [self releaseRepresentedObjects:[NSApp mainMenu]];
+
/* Kill the playlist, so that it doesn't accept new request
* such as the play request from vlc.c (we are a blocking interface). */
p_playlist = pl_Hold( p_intf );
More information about the vlc-devel
mailing list