Bladeren bron

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

nor..67 12 jaren geleden
bovenliggende
commit
ada9ee38b4

+ 14 - 0
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<Object>() {
+
+            public Object call() throws Exception {
+                rootNode.detachAllChildren();
+                return null;
+            }
+        });
+    }
+
     public void setCamFocus(final Vector3f focus) {
         SceneApplication.getApplication().enqueue(new Callable<Object>() {
 

+ 2 - 4
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();
     }