【问题标题】:Crash on Application Quit应用程序退出崩溃
【发布时间】:2013-12-16 10:48:58
【问题描述】:

谁能帮我解决这个崩溃。当应用程序退出时会发生这种情况,但并非总是如此。

Application Specific Information:
objc_msgSend() selector name: respondsToSelector:
Performing @selector(terminate:) from sender NSMenuItem 0x34cfd0

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x979414cc objc_msgSend + 44
1   com.apple.MyApp                 0x00026d9f -[MyAppController applicationShouldTerminate:] + 398
2   com.apple.AppKit                0x91086dc2 -[NSApplication _docController:shouldTerminate:] + 83
3   com.apple.AppKit                0x91086cb4 __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke + 140
4   com.apple.AppKit                0x910869c0 -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1304
5   com.apple.AppKit                0x9108646b -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 266
6   com.apple.AppKit                0x91086103 -[NSApplication _shouldTerminate] + 760
7   com.apple.AppKit                0x90f88008 -[NSApplication terminate:] + 1139
8   libobjc.A.dylib                 0x97957283 -[NSObject performSelector:withObject:] + 70
9   com.apple.AppKit                0x90f2fd75 -[NSApplication sendAction:to:from:] + 438
10  com.apple.AppKit                0x90f4c315 -[NSMenuItem _corePerformAction] + 486
11  com.apple.AppKit                0x90f4c01a -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 163
12  com.apple.AppKit                0x90f4b6c9 -[NSMenu _performActionWithHighlightingForItemAtIndex:sendAccessibilityNotification:] + 79
13  com.apple.AppKit                0x90f4b675 -[NSMenu _performActionWithHighlightingForItemAtIndex:] + 48
14  com.apple.AppKit                0x90f4b022 -[NSMenu performKeyEquivalent:] + 294
15  com.apple.AppKit                0x90f47735 -[NSApplication _handleKeyEquivalent:] + 938
16  com.apple.AppKit                0x90eb0cbe -[NSApplication sendEvent:] + 3911
17  com.apple.AppKit                0x90cf56cc -[NSApplication run] + 823
18  com.apple.AppKit                0x90cde558 NSApplicationMain + 1165
19  com.apple.MyApp                 0x00111c9a main + 728
20  com.apple.MyApp                 0x00002401 start + 53

有时我在退出时崩溃时会收到以下崩溃日志,但并非总是如此。

objc_msgSend() selector name: respondsToSelector:
objc[33814]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x99546d47 objc_msgSend + 23
1   com.apple.MyApp                 0x0001c574 -[MyAppController applicationShouldTerminate:] + 390
2   com.apple.AppKit                0x915f6701 -[NSApplication _docController:shouldTerminate:] + 83
3   com.apple.AppKit                0x917240ff __-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke_1 + 228
4   com.apple.AppKit                0x91730f86 -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1693
5   com.apple.AppKit                0x91729ec6 -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 310
6   com.apple.AppKit                0x915fdb15 -[NSApplication _shouldTerminate] + 889
7   com.apple.AppKit                0x91334332 -[NSApplication terminate:] + 1219
8   com.apple.CoreFoundation        0x90c1dd11 -[NSObject performSelector:withObject:] + 65
9   com.apple.AppKit                0x914371ff -[NSApplication sendAction:to:from:] + 232
10  com.apple.AppKit                0x9152ad8b -[NSMenuItem _corePerformAction] + 536
11  com.apple.AppKit                0x9152aa08 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 171
12  com.apple.AppKit                0x9152a091 -[NSMenu _performActionWithHighlightingForItemAtIndex:sendAccessibilityNotification:] + 79
13  com.apple.AppKit                0x9152a03d -[NSMenu _performActionWithHighlightingForItemAtIndex:] + 48
14  com.apple.AppKit                0x914a3923 -[NSMenu performKeyEquivalent:] + 306
15  com.apple.AppKit                0x914a2392 -[NSApplication _handleKeyEquivalent:] + 594
16  com.apple.AppKit                0x91397cef -[NSApplication sendEvent:] + 5772
17  com.apple.AppKit                0x91329459 -[NSApplication run] + 1007
18  com.apple.AppKit                0x915babf1 NSApplicationMain + 1054
19  com.apple.MyApp                 0x0010094b main + 216
20  com.apple.MyApp                 0x0000264d start + 53

【问题讨论】:

  • 向我们展示您在哪里实现了terminate: 方法的代码。
  • @Virussmca:他说不总是,如果不实施,那将总是!!!
  • @AnoopVaidya:您在哪里看到有时有问题?我还没见过,
  • @Virussmca:那是错字,我已经更新了……not always
  • @Virussmca :“主菜单退出”连接到 XIB 中文件所有者的 - (void)terminate:(id)sender。其中文件的所有者属于“NSApplication”类。文件所有者的委托只不过是符合“NSApplicationDelegate”的“MyAppController”。那么方法“终止:”必须被覆盖的点在哪里。

标签: objective-c cocoa nsapplication nsapplication-delegate


【解决方案1】:

首先要看的地方当然是你的-[MyAppController applicationShouldTerminate:],假设你已经实现了。您可能指的是已经发布的对象(这是 ARC 吗?此类错误的最常见原因是未能使用 ARC。)

如果您尚未实现applicationShouldTerminate:,则可能是您过度释放了应用委托本身。 NSZombies 可以帮助诊断。

【讨论】:

  • 我没有看到任何应用委托被释放的地方
猜你喜欢
  • 1970-01-01
  • 2016-06-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多