SDK:
- make SceneExplorerProperty use mutex less often git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10086 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
08212605bc
commit
e84105307c
@ -118,31 +118,43 @@ public class SceneExplorerProperty<T> extends PropertySupport.Reflection<T> {
|
|||||||
if (!editable) {
|
if (!editable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mutex.postWriteRequest(new Runnable() {
|
final T realValue = getSuperValue();
|
||||||
public void run() {
|
if ((objectLocal == null) && !inited) {
|
||||||
T realValue = getSuperValue();
|
mutex.postWriteRequest(new Runnable() {
|
||||||
if ((objectLocal == null) && !inited) {
|
public void run() {
|
||||||
inited = true;
|
inited = true;
|
||||||
T newObject = duplicateObject(realValue);
|
T newObject = duplicateObject(realValue);
|
||||||
notifyListeners(PROP_INIT_CHANGE, null, newObject);
|
notifyListeners(PROP_INIT_CHANGE, null, newObject);
|
||||||
objectLocal = duplicateObject(realValue);
|
objectLocal = duplicateObject(realValue);
|
||||||
} else if ((objectLocal != null) && !objectLocal.equals(realValue)) {
|
}
|
||||||
|
});
|
||||||
|
} else if ((objectLocal != null) && !objectLocal.equals(realValue)) {
|
||||||
|
mutex.postWriteRequest(new Runnable() {
|
||||||
|
public void run() {
|
||||||
T oldObject = objectLocal;
|
T oldObject = objectLocal;
|
||||||
T newObject = duplicateObject(realValue);
|
T newObject = duplicateObject(realValue);
|
||||||
notifyListeners(PROP_SCENE_CHANGE, oldObject, newObject);
|
notifyListeners(PROP_SCENE_CHANGE, oldObject, newObject);
|
||||||
objectLocal = newObject;
|
objectLocal = newObject;
|
||||||
} else if ((objectLocal == null) && (realValue != null)) {
|
}
|
||||||
|
});
|
||||||
|
} else if ((objectLocal == null) && (realValue != null)) {
|
||||||
|
mutex.postWriteRequest(new Runnable() {
|
||||||
|
public void run() {
|
||||||
T newObject = duplicateObject(realValue);
|
T newObject = duplicateObject(realValue);
|
||||||
notifyListeners(PROP_SCENE_CHANGE, null, newObject);
|
notifyListeners(PROP_SCENE_CHANGE, null, newObject);
|
||||||
objectLocal = duplicateObject(realValue);
|
objectLocal = duplicateObject(realValue);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
public T getValue() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
||||||
return objectLocal;
|
return mutex.readAccess(new Mutex.Action<T>() {
|
||||||
|
public T run() {
|
||||||
|
return objectLocal;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -218,10 +230,11 @@ public class SceneExplorerProperty<T> extends PropertySupport.Reflection<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private T duplicateObject(T a) {
|
private T duplicateObject(T a) {
|
||||||
T obj = a;
|
|
||||||
if (primitive) {
|
if (primitive) {
|
||||||
return obj;
|
return a;
|
||||||
} else if (cloneable) {
|
}
|
||||||
|
T obj = null;
|
||||||
|
if (cloneable) {
|
||||||
try {
|
try {
|
||||||
obj = (T) a.getClass().getMethod("clone").invoke(a);
|
obj = (T) a.getClass().getMethod("clone").invoke(a);
|
||||||
} catch (IllegalAccessException ex) {
|
} catch (IllegalAccessException ex) {
|
||||||
@ -252,6 +265,9 @@ public class SceneExplorerProperty<T> extends PropertySupport.Reflection<T> {
|
|||||||
Exceptions.printStackTrace(ex);
|
Exceptions.printStackTrace(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (obj == null) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user