From 2ac567a5e5cce9e06abf29ce2a4a89edef814c45 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Wed, 30 Jan 2013 03:54:40 +0000 Subject: [PATCH] SDK: - cleanup offscene panel in model importer when import fails git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10239 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/com/jme3/gde/core/scene/OffScenePanel.java | 14 ++++++++++++++ .../modelimporter/ModelImporterVisualPanel3.java | 6 ++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/scene/OffScenePanel.java b/sdk/jme3-core/src/com/jme3/gde/core/scene/OffScenePanel.java index 943c8d302..bd297212b 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/scene/OffScenePanel.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/scene/OffScenePanel.java @@ -307,6 +307,20 @@ public class OffScenePanel extends javax.swing.JPanel implements SceneProcessor }); } + /** + * threadsafe detach from root node + * @param spat + */ + public void detachAll() { + SceneApplication.getApplication().enqueue(new Callable() { + + public Object call() throws Exception { + rootNode.detachAllChildren(); + return null; + } + }); + } + public void setCamFocus(final Vector3f focus) { SceneApplication.getApplication().enqueue(new Callable() { diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.java index a70c13786..3bff3dac0 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.java +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel3.java @@ -59,6 +59,7 @@ public final class ModelImporterVisualPanel3 extends JPanel { mainKey = (AssetKey) wiz.getProperty("mainkey"); data = (AssetData) wiz.getProperty("assetdata"); loadModel(); + offPanel.detachAll(); if (currentModel != null) { logger.log(Level.INFO, "Attaching model {0}", currentModel); offPanel.attach(currentModel); @@ -73,10 +74,7 @@ public final class ModelImporterVisualPanel3 extends JPanel { wiz.putProperty("assetlist", assetKeys); wiz.putProperty("failedlist", failedKeys); wiz.putProperty("model", currentModel); - if (currentModel != null) { - logger.log(Level.INFO, "Detaching model {0}", currentModel); - offPanel.detach(currentModel); - } + offPanel.detachAll(); logger.log(Level.INFO, "Stop offview panel"); offPanel.stopPreview(); }