Using the documentation provided by Apple to create an application preferences window that doesn't require any extra code, I seem to have triggered a crash that I cannot trace.
While the stuff from Apple is older, I believe I have the settings pretty much the same as shown here:
When I run my application (Hcode) and go to the preferences menu item, it brings up the proper window with the defaults I specified in the bindings with the exception of the Spaces per tab is blank (no idea how to fix this).
When the window is closed, the application crashes with a backtrace similar to this:
(gdb) bt
#0 0x00007fff800cb1d4 in objc_msgSend_vtable5 ()
#1 0x00007fff80447cf3 in -[NSMenu _enableItem:] ()
#2 0x00007fff80447ad8 in -[NSCarbonMenuImpl _carbonUpdateStatusEvent:handlerCallRef:] ()
#3 0x00007fff8042b3b0 in NSSLMMenuEventHandler ()
#4 0x00007fff80e06b57 in DispatchEventToHandlers ()
#5 0x00007fff80e060a6 in SendEventToEventTargetInternal ()
#6 0x00007fff80e23d85 in SendEventToEventTarget ()
#7 0x00007fff80e52e61 in SendHICommandEvent ()
#8 0x00007fff80e66357 in UpdateHICommandStatusWithCachedEvent ()
#9 0x00007fff80e02a6d in HIApplication::EventHandler ()
#10 0x00007fff80e06b57 in DispatchEventToHandlers ()
#11 0x00007fff80e060a6 in SendEventToEventTargetInternal ()
#12 0x00007fff80e23d85 in SendEventToEventTarget ()
#13 0x00007fff80e6599b in SendMenuOpening ()
#14 0x00007fff80e65388 in DrawTheMenu ()
#15 0x00007fff80e65149 in MenuChanged ()
#16 0x00007fff80e643d4 in TrackMenuCommon ()
#17 0x00007fff8开发者_运维知识库0e60dbe in MenuSelectCore ()
#18 0x00007fff80e60596 in _HandleMenuSelection2 ()
#19 0x00007fff802fc3b9 in _NSHandleCarbonMenuEvent ()
#20 0x00007fff802cfeda in _DPSNextEvent ()
#21 0x00007fff802cf379 in -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#22 0x00007fff8029505b in -[NSApplication run] ()
#23 0x00007fff8028dd7c in NSApplicationMain ()
#24 0x0000000100001cac in main (argc=1, argv=0x7fff5fbff5e0) at /Users/iaefai/Projects/Hcode/Source/main.m:13
I am at a complete loss as to what the problem is. Is there potentially a better way of doing this?
Your stack trace shows a crash in updating/drawing a menu item. This seems to have nothing to do with your bound checkbox.
Run your app in Instruments with its Zombies template; it'll probably tell you that you (or Cocoa) sent a message to a deallocated object. Find out what the object was, and fix the under-retention or over-release that caused it to die prematurely.
精彩评论