Re: Must remove submenu when dealloccing NSMenuItem?
Re: Must remove submenu when dealloccing NSMenuItem?
- Subject: Re: Must remove submenu when dealloccing NSMenuItem?
- From: Michael Nickerson <email@hidden>
- Date: Thu, 22 Feb 2007 10:54:13 -0500
On Feb 22, 2007, at 12:39 AM, Jerry Krinock wrote:
[snip]
// Add Menu item "Copy to ->"
menuItem = [[NSMenuItem allocWithZone:[NSMenu menuZone]]
initWithTitle:NSLocalizedString(@"Copy to", nil)
action:nil
keyEquivalent:@""];
bookmarksHierarchicalMenu = [[SSMenu alloc]
initWithOwningMenuItem:menuItem] ;
// Note: owningMenuItem is a convenience, so I don't have to
// use -supermenu and then enumerate through its -itemArray.
// So as not to create a retain cycle, it is a "weak reference";
// it is ^not^ retained by SSMenu
[menuItem setSubmenu:bookmarksHierarchicalMenu] ;
[bookmarksHierarchicalMenu setDelegate:
[self bookmarksHierarchicalMenuDataSource]] ;
// The above is an instance of MenuOutlineDataSource, see below.
// In -awakeFromNib, it is initWithHost:self
// That is, this outline view is what I call the "host" of the
// MenuOutlineDataSource. (It's a weak reference, not retained)
[bookmarksHierarchicalMenu release] ;
[menuItem setTag:2] ;
[menu addItem:menuItem];
[menuItem release];
// Snipped out adding additional menu items
// Snipped out releases of other local variables
return [menu autorelease] ;
}
[snip]
Does it change things if you do it this way instead? Set up your
bookmarksHierarchicalMenu the same way, but don't use [menuItem
setSubmenu:], then...
[menuItem setTag:2];
[menu addItem:menuItem];
[menu setSubmenu:bookmarksHierarchicalMenu forItem:menuItem];
[menuItem release];
[bookMarksHierarchicalMenu release];
?
------------------------------------------------
Darkshadow
(aka Michael Nickerson)
http://www.nightproductions.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden