Is there a good reason why you're not using automatic menu enabling? https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MenuList/Articles/EnablingMenuItems.html
On 16 Apr 2012, at 13:27, Jerry Krinock wrote: > When I have a menu item which needs to be disabled based on current > conditions, I implement -menuNeedsUpdate: in its menu's delegate, grab the > item by its tag, and then -setEnabled:(YES or NO). I've been doing this for > years. > > Today I have a problem. If I set a particular item in the Application menu > to be disabled in this way, a few milliseconds later, Cocoa resends > -[NSMenuItem setEnabled:] with parameter YES, thus re-enabling the item. > Culprit is -[NSCarbonMenuImpl _carbonUpdateStatusEvent:handlerCallRef:]. > Complete call stack is shown below. > > What is doing this? > > I've worked around the problem by following setEnabled:NO with setAction:NULL. > > Thanks, > > Jerry Krinock > > * Mystery Call Stack > > (Note that I tapped into -[NSMenuItem setEnabled:] using Method Replacement, > because breaking to Xcode when updating a menu aborts the menu updating, and > also gdb was giving me crap for some reason when I set breakpoint actions to > print the registers in -[NSMenuItem setEnabled:].) > > 1 MyFramework 0x001cf3e8 > -[NSMenuItem(DebugByReplacingMethod) replacement_setEnabled:] + 136 > 2 AppKit 0x90d614c4 -[NSMenu _enableItem:] + > 1081 > 3 AppKit 0x90ef88f6 -[NSCarbonMenuImpl > _carbonUpdateStatusEvent:handlerCallRef:] + 559 > 4 AppKit 0x90e70d02 NSSLMMenuEventHandler + 452 > 5 HIToolbox 0x9064d62c > _Z22_InvokeEventHandlerUPPP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvPFlS0_S2_S3_E > + 36 > 6 HIToolbox 0x904c8f4f > _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec > + 1602 > 7 HIToolbox 0x904c83cc > _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec > + 482 > 8 HIToolbox 0x904dd0d5 SendEventToEventTarget + 76 > 9 HIToolbox 0x9064daf0 > _ZL18SendHICommandEventmPK9HICommandmmhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef > + 482 > 10 HIToolbox 0x9064dbf2 > UpdateHICommandStatusWithCachedEvent + 70 > 11 HIToolbox 0x904c4aa3 > _ZN13HIApplication12EventHandlerEP25OpaqueEventHandlerCallRefP14OpaqueEventRefPv > + 2699 > 12 HIToolbox 0x9064d62c > _Z22_InvokeEventHandlerUPPP25OpaqueEventHandlerCallRefP14OpaqueEventRefPvPFlS0_S2_S3_E > + 36 > 13 HIToolbox 0x904c8f4f > _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec > + 1602 > 14 HIToolbox 0x904c83cc > _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec > + 482 > 15 HIToolbox 0x904dd0d5 SendEventToEventTarget + 76 > 16 HIToolbox 0x906a1310 > _ZL15SendMenuOpeningP14MenuSelectDataP8MenuDatadmmP14__CFDictionaryhPh + 847 > 17 HIToolbox 0x906a567c > _ZL11DrawTheMenuP14MenuSelectDataPP9__CFArrayhPh + 202 > 18 HIToolbox 0x906a5bee > _ZL11MenuChangedP14MenuSelectDatahh + 608 > 19 HIToolbox 0x9051529d > _ZL15TrackMenuCommonR14MenuSelectDataPh + 1235 > 20 HIToolbox 0x906a9474 > _ZL14MenuSelectCoreP8MenuData5PointdmPP13OpaqueMenuRefPt + 420 > 21 HIToolbox 0x9051152e _HandleMenuSelection2 + 636 > 22 HIToolbox 0x905112ad _HandleMenuSelection + 53 > 23 AppKit 0x90d6cd4a _NSHandleCarbonMenuEvent + > 302 > 24 AppKit 0x90cfd08a _DPSNextEvent + 2196 > 25 AppKit 0x90cfc306 -[NSApplication > nextEventMatchingMask:untilDate:inMode:dequeue:] + 113 > 26 AppKit 0x90cf8675 -[NSApplication run] + 911 > 27 AppKit 0x90f8c261 NSApplicationMain + 1054 > 28 MyApp 0x00001e15 main + 245 > 29 MyApp 0x00001d15 start + 53 > _______________________________________________ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > 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: > https://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net > > This email sent to cocoa...@mikeabdullah.net _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com