From 4ecc884e28c0a8afb4d377bf99a6dbba6272a917 Mon Sep 17 00:00:00 2001 From: Nicola Pero Date: Sat, 23 Feb 2002 11:16:59 +0000 Subject: [PATCH] Various comments added git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@12698 72102866-910b-0410-8b05-ffd578937521 --- Source/NSMenu.m | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Source/NSMenu.m b/Source/NSMenu.m index a0cf3efd9..152254243 100644 --- a/Source/NSMenu.m +++ b/Source/NSMenu.m @@ -102,9 +102,9 @@ static NSNotificationCenter *nc; } } +/* Create a non autorelease window for this menu. */ - (NSPanel*) _createWindow { - // Create a non autorelease window for this menu NSPanel *win = [[NSPanel alloc] initWithContentRect: NSZeroRect styleMask: NSBorderlessWindowMask @@ -155,6 +155,8 @@ static NSNotificationCenter *nc; - (void) dealloc { + NSDebugLog (@"NSMenu `%@' dealloc", _title); + [nc removeObserver: self]; RELEASE(_notifications); @@ -195,6 +197,11 @@ static NSNotificationCenter *nc; // Transient windows private stuff. // _oldAttachedMenu = nil; + /* Please note that we own all this menu network of objects. So, + none of these objects should be retaining us. When we are deallocated, + we release all the objects we own, and that should cause deallocation + of the whole menu network. */ + // Create the windows that will display the menu. _aWindow = [self _createWindow]; _bWindow = [self _createWindow]; @@ -205,7 +212,8 @@ static NSNotificationCenter *nc; // Create the title view height = [[_view class] menuBarHeight]; - _titleView = [[NSMenuWindowTitleView alloc] initWithFrame: NSMakeRect(0, 0, 50, height)]; + _titleView = [[NSMenuWindowTitleView alloc] initWithFrame: + NSMakeRect(0, 0, 50, height)]; [_titleView setMenu: self]; contentView = [_aWindow contentView]; @@ -553,6 +561,7 @@ static NSNotificationCenter *nc; - (void) setSupermenu: (NSMenu *)supermenu { + /* The supermenu retains us (indirectly). Do not retain it. */ _superMenu = supermenu; } @@ -929,7 +938,7 @@ static NSNotificationCenter *nc; if (sub != nil) { [sub setSupermenu: nil]; - [self setSubmenu: sub forItem: item]; + [self setSubmenu: sub forItem: item]; } } [self setMenuChangedMessagesEnabled: YES];