首页 / 浏览问题 / 组件GIS / 问题详情
新建场景窗口程序,桌面奔溃
34EXP 2023年06月06日

组件开发,使用如下代码新建场景窗口,在执行这一句时SuperMap桌面直接崩了,

IFormScene formScene = (IFormScene) FormUtilities.fireNewWindowEvent(WindowType.SCENE);

产生错误信息

# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_UNCAUGHT_CXX_EXCEPTION (0xe06d7363) at pc=0x00007ff839764fd9, pid=20948, tid=0x0000000000000bec
#
# JRE version: OpenJDK Runtime Environment (8.0_332-b09) (build 1.8.0_332-b09)
# Java VM: OpenJDK 64-Bit Server VM (25.332-b09 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [KERNELBASE.dll+0x34fd9]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

1个回答

您好,出现JVM崩溃是因为 FormUtilities.fireNewWindowEvent(WindowType.SCENE) 接口必须在 UI 线程中执行,根据您的代码逻辑,有以下 2 中调整方案:

  1. 直接将截图中的代码逻辑提出子线程;
    public void run() {
    	IFormScene formScene = (IFormScene) FormUtilities.fireNewWindowEvent(WindowType.SCENE);
    	SceneControl sceneControl = formScene.getSceneControl();
    	Scene scene = sceneControl.getScene();
    	scene.refresh();
    	scene.setLookAt(scene.getLookAt());
    }

  2. 将截图中的代码逻辑全部放入 SwingUtilities.invokeLater 里面。
    public void run() {
    	new Thread(()->{
    		SwingUtilities.invokeLater(()->{
    			IFormScene formScene = (IFormScene) FormUtilities.fireNewWindowEvent(WindowType.SCENE);
    			SceneControl sceneControl = formScene.getSceneControl();
    			Scene scene = sceneControl.getScene();
    			scene.refresh();
    			scene.setLookAt(scene.getLookAt());
    		});
    	}).start();
    }

希望可以帮到您。

2,253EXP 2023年06月06日
...