gpt4 book ai didi

java - OS-X 上的 VTK Java、Cocoa 异常

转载 作者:行者123 更新时间:2023-12-01 05:19:05 25 4
gpt4 key购买 nike

我安装了 VTK 工具包,并在 Eclipse 中使用 VTK 的 Java 包装器。我将 vtk.jar 添加到我的 java 项目中,并将环境变量设置为指向我的 VTK 安装。基本上,它正在发挥作用。找到 vtk 类等并启动程序,至少直到我显示窗口为止。

例如以下示例程序: http://www.vtk.org/Wiki/VTK/Examples/Java/Imaging/ImageTest

如果我运行它,OS-X(或 Cocoa)会抛出以下异常,说明 UndoManager 存在一些问题:

我不知道我做错了什么或者是什么导致了这个问题,有人有什么想法吗?

2012-05-22 22:48:09.093 java[925:1a03] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-833.25/Misc.subproj/NSUndoManager.m:324
2012-05-22 22:48:09.093 java[925:1a03] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2012-05-22 22:48:09.096 java[925:1a03] (
0 CoreFoundation 0x00007fff9363cf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8aa9fd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff9363cd8a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00007fff910a371f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
4 Foundation 0x00007fff9101295f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 144
5 AppKit 0x00000001025680ef -[NSApplication run] + 596
6 libvtkRendering.5.10.dylib 0x000000010ff8c2df -[vtkCocoaServer start] + 335
7 libvtkRendering.5.10.dylib 0x000000010ff8cf87 _ZN30vtkCocoaRenderWindowInteractor5StartEv + 293
8 libvtkRenderingJava.5.10.0.dylib 0x000000010f94f29e Java_vtk_vtkRenderWindowInteractor_Start_15 + 62
9 ??? 0x0000000103b70d6e 0x0 + 4357295470
10 ??? 0x0000000103b6585a 0x0 + 4357249114
)
2012-05-22 22:48:09.096 java[925:1a03] *** Assertion failure in +[NSUndoManager _endTopLevelGroupings], /SourceCache/Foundation/Foundation-833.25/Misc.subproj/NSUndoManager.m:324
2012-05-22 22:48:09.096 java[925:1a03] An uncaught exception was raised
2012-05-22 22:48:09.097 java[925:1a03] +[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.
2012-05-22 22:48:09.098 java[925:1a03] (
0 CoreFoundation 0x00007fff9363cf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8aa9fd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff9363cd8a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00007fff910a371f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
4 Foundation 0x00007fff9101295f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 144
5 AppKit 0x000000010256819c -[NSApplication run] + 769
6 libvtkRendering.5.10.dylib 0x000000010ff8c2df -[vtkCocoaServer start] + 335
7 libvtkRendering.5.10.dylib 0x000000010ff8cf87 _ZN30vtkCocoaRenderWindowInteractor5StartEv + 293
8 libvtkRenderingJava.5.10.0.dylib 0x000000010f94f29e Java_vtk_vtkRenderWindowInteractor_Start_15 + 62
9 ??? 0x0000000103b70d6e 0x0 + 4357295470
10 ??? 0x0000000103b6585a 0x0 + 4357249114
)
2012-05-22 22:48:09.098 java[925:1a03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+[NSUndoManager(NSInternal) _endTopLevelGroupings] is only safe to invoke on the main thread.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff9363cf56 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8aa9fd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff9363cd8a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00007fff910a371f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
4 Foundation 0x00007fff9101295f +[NSUndoManager(NSPrivate) _endTopLevelGroupings] + 144
5 AppKit 0x000000010256819c -[NSApplication run] + 769
6 libvtkRendering.5.10.dylib 0x000000010ff8c2df -[vtkCocoaServer start] + 335
7 libvtkRendering.5.10.dylib 0x000000010ff8cf87 _ZN30vtkCocoaRenderWindowInteractor5StartEv + 293
8 libvtkRenderingJava.5.10.0.dylib 0x000000010f94f29e Java_vtk_vtkRenderWindowInteractor_Start_15 + 62
9 ??? 0x0000000103b70d6e 0x0 + 4357295470
10 ??? 0x0000000103b6585a 0x0 + 4357249114
)
terminate called throwing an exception

建议的 VM 参数导致此错误:

2012-05-23 09:10:18.635 java[747:307] [Java CocoaComponent compatibility mode]: Enabled
2012-05-23 09:10:18.635 java[747:307] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
2012-05-23 09:10:18.985 java[747:d303] *** -[NSConditionLock unlock]: lock (<NSConditionLock: 0x7fa108c64600> '(null)') unlocked when not locked
2012-05-23 09:10:18.985 java[747:d303] *** Break on _NSLockError() to debug.

最佳答案

这可能是与 Cocoa 限制相关的问题,即某些事情只能在进程运行的第一个线程上运行。例如,SWT 事件循环也会出现同样的问题。问题是 main 方法不在第一个线程上执行,因为它是为 AWT 的事件循环保留的——出于同样的原因。解决方法:使用 JVM 开关 -XstartOnFirstThread

关于java - OS-X 上的 VTK Java、Cocoa 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10710064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com