Cocoa 绑定和应用程序首选项 - 崩溃
使用Apple 提供的文档创建不需要任何内容的应用程序首选项窗口额外的代码,我似乎触发了无法追踪的崩溃。
虽然 Apple 的东西比较旧,但我相信我的设置与此处所示的设置几乎相同:
当我运行我的应用程序时 (Hcode)并转到首选项菜单项,它会打开正确的窗口,其中包含我在绑定中指定的默认值,但每个选项卡的空格为空(不知道如何解决此问题)。
当窗口关闭时,应用程序崩溃并出现类似于以下的回溯:
(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 0x00007fff80e60dbe 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
我完全不知道问题是什么。有没有更好的方法可以做到这一点?
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 0x00007fff80e60dbe 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的堆栈跟踪显示更新/绘制菜单项时发生崩溃。这似乎与您绑定的复选框无关。
使用其 Zombies 模板在 Instruments 中运行您的应用程序;它可能会告诉您,您(或 Cocoa)向已释放的对象发送了一条消息。找出该对象是什么,并修复导致其过早死亡的保留不足或过度释放。
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.