在创建和销毁NSPopover对象方面,我似乎遇到了一个重大的问题。NSPopover被设置为实例变量。即使要检查popover是否为零,如果不是为零,它仍然以SIGSEGV结尾。几个小时以来,我一直在试图解决这个问题,但什么也没想出来。
- (void)addMenuIconPopup
{
MenuPopupViewController *popoverController = [[MenuPopupViewController alloc] init];
if(menuIconPopover != nil) {
[self removeMenuIconPopup];
}
menuIconPopover = [[NSPopover alloc] init];
[menuIconPopover setContentViewController:popoverController];
[menuIconPopover showRelativeToRect:[[statusItem view] frame]
ofView:[statusItem view]
preferredEdge:NSMinYEdge];
}
- (void)removeMenuIconPopup
{
if(menuIconPopover != nil) {
[menuIconPopover close];
menuIconPopover = nil;
}
}编辑:,似乎是NSPopover本身造成了挂起。以下是流程示例的相关部分(将可能在NDA下的部分空白)。
2762 Thread_2921859
2762 thread_start (in libsystem_c.dylib) + 13 [0x7fff8f0011e1]
2762 _pthread_start (in libsystem_c.dylib) + 327 [0x7fff8f0147a2]
2762 ??? (in variouslibrary.dylib) load address 0x1000cd000 + 0xb9461 [0x100186461]
2762 ??? (in variouslibrary.dylib) load address 0x1000cd000 + 0x26390 [0x1000f3390]
2762 VariousControllerDelegateListener::onConnect(VariousController::Controller const&) (in App) + 93 [0x10001d4cd] VariousControllerObjectiveC.mm:1752
2762 -[VariousControllerController onConnect:] (in App) + 126 [0x100006eae] VariousControllerController.m:215
2762 -[TutorialWindowController variousControllerConnected] (in App) + 88 [0x100031a78] TutorialWindowController.m:93
2762 _NSPopoverCloseAndAnimate (in AppKit) + 840 [0x7fff89bac8d7]
2762 -[NSWindow orderWindow:relativeTo:] (in AppKit) + 159 [0x7fff8950ac1f]
2762 -[NSWindow _doOrderWindow:relativeTo:findKey:forCounter:force:isModal:] (in AppKit) + 668 [0x7fff8950af28]
2762 -[_NSWindowTransformAnimation startAnimation] (in AppKit) + 512 [0x7fff8936b95c]
2762 _NSWindowExchange (in AppKit) + 376 [0x7fff89a27555]
2762 -[NSWindow _reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] (in AppKit) + 1377 [0x7fff8950ba18]
2762 -[NSNextStepFrame displayIfNeeded] (in AppKit) + 84 [0x7fff895d8e64]
2762 -[NSView displayIfNeeded] (in AppKit) + 1044 [0x7fff8944e981]
2762 -[NSView _sendViewWillDrawInRect:clipRootView:] (in AppKit) + 1195 [0x7fff8948240a]
2762 -[NSViewHierarchyLock lockForReadingWithExceptionHandler:] (in AppKit) + 378 [0x7fff894259e1]
2762 _pthread_cond_wait (in libsystem_c.dylib) + 869 [0x7fff8f018fe9]
2762 __psynch_cvwait (in libsystem_kernel.dylib) + 10 [0x7fff8a53d0fa]发布于 2013-06-28 01:22:45
我最终解决了这个问题,只需调用主线程上的函数,通过
[self performSelectorOnMainThread:@selector(addMenuIconPopup) withObject:(nil) waitUntilDone:NO];https://stackoverflow.com/questions/17180796
复制相似问题