在applicationDidFinishLaunching之前调用NSApplication applicationShouldTerminate

时间:2013-10-31 13:51:17

标签: objective-c macos cocoa nsapplication-delegate

我遇到了一个奇怪的问题:在applicationDidFinishLaunching的{​​{1}}中初始化了一个单例,但在某些情况下我会收到AppDelegate的崩溃报告(EXC_CRASH )和这样的堆栈跟踪:

SIGSEGV

所以我看到我的单身人士正在尝试分配并失败,所以我认为0 com.name.myapp 0x000000010f723bae -[MySingleton .cxx_construct] (common_bootstrap.h:57) 1 libobjc.A.dylib 0x00007fff91339baa object_cxxConstructFromClass(objc_object*, objc_class*) + 151 2 libobjc.A.dylib 0x00007fff913367e4 object_cxxConstruct + 25 3 libobjc.A.dylib 0x00007fff91336795 _objc_constructOrFree + 21 4 libobjc.A.dylib 0x00007fff9134a49d +[NSObject allocWithZone:] + 16 5 com.name.myapp 0x000000010f722a11 __32+[MySingleton sharedInstance]_block_invoke (MySingleton.mm:124) 6 libdispatch.dylib 0x00007fff9377a2ad _dispatch_client_callout + 8 7 libdispatch.dylib 0x00007fff9377a21c dispatch_once_f + 79 8 com.name.myapp 0x000000010f7229f5 +[MySingleton sharedInstance] (once.h:68) 9 com.name.myapp 0x000000010f719480 -[AppDelegate applicationShouldTerminate:] (AppDelegate.m:673) 10 com.apple.AppKit 0x00007fff8d017471 -[NSApplication _docController:shouldTerminate:] + 69 11 com.apple.AppKit 0x00007fff8d017383 __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke + 152 12 com.apple.AppKit 0x00007fff8d017122 -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1292 13 com.apple.AppKit 0x00007fff8d016bbf -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 265 14 com.apple.AppKit 0x00007fff8d01688c -[NSApplication _shouldTerminate] + 663 15 com.apple.AppKit 0x00007fff8d052a34 -[NSApplication(NSAppleEventHandling) _handleAEQuit] + 357 16 com.apple.AppKit 0x00007fff8ccb7213 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 282 17 com.apple.Foundation 0x00007fff92bf1eaa -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 294 18 com.apple.Foundation 0x00007fff92bf1d1d _NSAppleEventManagerGenericHandler + 106 19 com.apple.AE 0x00007fff8c139e1f aeDispatchAppleEvent(AEDesc const*, AEDesc*, unsigned int, unsigned char*) + 381 20 com.apple.AE 0x00007fff8c139c32 dispatchEventAndSendReply(AEDesc const*, AEDesc*) + 31 21 com.apple.AE 0x00007fff8c139b36 aeProcessAppleEvent + 315 22 com.apple.HIToolbox 0x00007fff8bced5f1 AEProcessAppleEvent + 56 23 com.apple.AppKit 0x00007fff8ccb30f6 _DPSNextEvent + 1026 24 com.apple.AppKit 0x00007fff8ccb28db -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122 25 com.apple.AppKit 0x00007fff8cca69cc -[NSApplication run] + 553 26 com.apple.AppKit 0x00007fff8cc91803 NSApplicationMain + 940 27 com.name.myapp 0x000000010f716ec4 start + 52 从未被调用过。

为什么OS X会在启动之前尝试终止我的应用程序?

0 个答案:

没有答案