NSPopupButton & lazy menu construction ->crashing
NSPopupButton & lazy menu construction ->crashing
- Subject: NSPopupButton & lazy menu construction ->crashing
- From: Steve Cronin <email@hidden>
- Date: Sun, 17 Feb 2008 03:27:05 -0600
Folks;
I'm trying to do something that seems pretty simple but I have spent
hours and hours trying to get it to work....
Drag a popup button off IB (TIger BTW) make no changes - no
connections, no targets, no bindings...
Register for the 'NSPopUpButtonCellWillPopUpNotification'.
When the user presses on the popup button the notification fires and
I construct a menu ala:
NSMenu *popupMenu = [[[NSMenu alloc] initWithTitle:@"__"] autorelease];
[popupMenu setAutoenablesItems:NO];
NSEnumerator *tEnm = [myArray objectEnumerator];
NSString *str;
NSMenuItem *mI;
while ((str = [tEnm nextObject])!=nil) {
mI = [[[NSMenuItem alloc] initWithTitle:str action:@selector(xyz:)
keyEquivalent:@""] autorelease];
[popupMenu addItem:mI];
}
[myPopupMenu setMenu:popupMenu];
This all works dandy! Except for the fact that the initial view of
the popup does not show a value from the array at hand.
BUT that is not my main problem!!
After several uses of the popup (2-5x) the app will reliably crash:
#0 0x90a594c0 in objc_msgSend
#1 0x00000009 in ??
#2 0x932883e4 in +[NSMenu(NSKeyEquivalents)
_recursivelyAddItemsInMenu:toTable:]
#3 0x9328828c in +[NSMenu(NSKeyEquivalents)
_registerMenuForKeyEquivalentUniquing:]
#4 0x9328ccb8 in -[NSMenu _setOwnedByPopUp:]
#5 0x932c7f45 in -[NSPopUpButtonCell setMenu:]
#6 0x933dbec6 in -[NSPopUpButton setMenu:]
#7 0x045eae26 in -[MyWindowController popupMenuConstructor:] at
MyWindowController.m:841
#8 0x927f015b in _nsnote_callback
#9 0x908563ca in __CFXNotificationPost
#10 0x9084db69 in _CFXNotificationPostNotification
#11 0x927e8704 in -[NSNotificationCenter
postNotificationName:object:userInfo:]
#12 0x927ef6a9 in -[NSNotificationCenter postNotificationName:object:]
#13 0x93438fc9 in -[NSPopUpButtonCell _handleWillPopUpNotification]
#14 0x93438f01 in -[NSPopUpButtonCell attachPopUpWithFrame:inView:]
#15 0x93438d4d in -[NSPopUpButtonCell
trackMouse:inRect:ofView:untilMouseUp:]
#16 0x933b5b39 in -[NSControl mouseDown:]
#17 0x933733e3 in -[NSWindow sendEvent:]
#18 0x93365384 in -[NSApplication sendEvent:]
#19 0x9328fe1e in -[NSApplication run]
#20 0x93283d4f in NSApplicationMain
#21 0x00405ffc in main at main.m:18
Can someone shed some light on this?
Thanks for all thoughts!
Steve
_______________________________________________
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