我正在使用 Cocoa、OpenGL 应用程序遇到一个奇怪的问题。每当我启动我的应用程序时,我都会在控制台上收到以下与 eh NSUndoManager 相关的消息/断言失败。顺便说一句,我没有使用撤消管理器。
2010-09-05 03:28:49.184 CocoaCoreTest[51721:a0f] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-751.29/Misc.subproj/NSUndoManager.m:271
2010-09-05 03:28:49.188 CocoaCoreTest[51721:a0f] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2010-09-05 03:28:49.189 CocoaCoreTest[51721:a0f] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-751.29/Misc.subproj/NSUndoManager.m:271
2010-09-05 03:28:49.190 CocoaCoreTest[51721:a0f] An uncaught exception was raised
2010-09-05 03:28:49.190 CocoaCoreTest[51721:a0f] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2010-09-05 03:28:49.192 CocoaCoreTest[51721:a0f] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00007fff83e97cc4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff883bb0f3 objc_exception_throw + 45
2 CoreFoundation 0x00007fff83e97ae7 +[NSException raise:format:arguments:] + 103
3 Foundation 0x00007fff84cf2d5a -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 198
4 Foundation 0x00007fff84c4b936 +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 140
5 AppKit 0x00007fff823219f9 -[NSApplication run] + 689
6 AppKit 0x00007fff8231a5f8 NSApplicationMain + 364
7 CocoaCoreTest 0x000000010003b753 main + 33
8 CocoaCoreTest 0x0000000100021608 start + 52
9 ??? 0x0000000000000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
我在主线程上运行我的 GUI,实际上我没有产生任何其他线程。当我为 x86_64 编译时,我在调试和发布模式下遇到了这个崩溃。然而,有趣的是,当我为 i386 编译时,并没有出现这个错误。
谢谢你的帮助!
弗洛里安