From 7bc7aed6d867612d1a4479c8160aa04ee130645a Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Sun, 20 Jan 2013 15:45:38 +0000 Subject: [PATCH] SDK: - Improve update logic in SceneExplorerProperty git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10117 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../properties/SceneExplorerProperty.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/SceneExplorerProperty.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/SceneExplorerProperty.java index 30d6632f4..5c7d4834b 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/properties/SceneExplorerProperty.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/SceneExplorerProperty.java @@ -66,6 +66,7 @@ public class SceneExplorerProperty extends PropertySupport.Reflection { public static final String PROP_USER_CHANGE = "PROP_USER_CHANGE"; public static final String PROP_INIT_CHANGE = "PROP_INIT_CHANGE"; private T objectLocal; + private boolean changing = false; private final boolean cloneable; private final boolean instantiable; private final boolean primitive; @@ -123,6 +124,9 @@ public class SceneExplorerProperty extends PropertySupport.Reflection { final T realValue = getSuperValue(); mutex.readAccess(new Runnable() { public void run() { + if (changing) { + return; + } if ((objectLocal == null) && !inited) { mutex.postWriteRequest(new Runnable() { public void run() { @@ -169,14 +173,20 @@ public class SceneExplorerProperty extends PropertySupport.Reflection { public void setValue(final T val) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { mutex.postWriteRequest(new Runnable() { public void run() { - logger.log(Level.FINE, "Set local value of {0}", objectLocal); + logger.log(Level.FINE, "Set local value to {0}", val); final T oldObject = objectLocal; + changing = true; objectLocal = val; final T sceneObject = duplicateObject(val); notifyListeners(PROP_USER_CHANGE, oldObject, objectLocal); SceneApplication.getApplication().enqueue(new Callable() { public Void call() throws Exception { - setSuperValue(sceneObject); + mutex.postWriteRequest(new Runnable() { + public void run() { + setSuperValue(sceneObject); + changing = false; + } + }); return null; } }); @@ -313,8 +323,9 @@ public class SceneExplorerProperty extends PropertySupport.Reflection { private void setSuperValue(T val, boolean undo) { try { if (undo) { - logger.log(Level.FINE, "Add undo for {0} on thread {1}"); - addUndo(duplicateObject(getSuperValue()), val); + T dupe = duplicateObject(getSuperValue()); + logger.log(Level.FINE, "Add undo for {0}", dupe); + addUndo(dupe, val); } logger.log(Level.FINE, "Set super value on thread {0}", Thread.currentThread().getName()); super.setValue(val);