NSMenuItemCell setMenuItem does not retain?
NSMenuItemCell setMenuItem does not retain?
- Subject: NSMenuItemCell setMenuItem does not retain?
- From: Steve Mills <email@hidden>
- Date: Fri, 02 Aug 2013 08:01:03 -0500
Is setMenuItem supposed to retain the item? We have some code written quite a while ago that looks like:
- (id)copyMixedCellForTableColumn:(NSTableColumn*)tableColumn withText:(FinUString)text
{
NSMenuItem* menuItem = [[[NSMenuItem alloc] initWithTitle:[NSString stringWithFinUString:text] action:nil keyEquivalent:@""] autorelease];
id cell = [[tableColumn dataCell] copy];
[cell setUsesItemFromMenu:NO];
[cell setMenuItem:menuItem];
return cell;
}
Under 10.7, we get a zombie overreleased crash when the autorelease pool goes to finally release this menu item. If we take out the autorelease, no crash. 10.8 seems to run OK and doesn't report a zombie, but I also can't see it leaking if I remove the autorelease. I'm not sure why. Maybe Instruments wasn't behaving. The docs for setUsesItemFromMenu shows a sample where the item is released.
--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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