From 2611139702b6acc46ab2049337a9a2467a0ca5ba Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Sun, 3 Apr 2011 04:46:03 +0000 Subject: [PATCH] * Fixed a possible issue where updateLogicalState could cause an IndexOutOfBoundsException git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7167 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/scene/Node.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/engine/src/core/com/jme3/scene/Node.java b/engine/src/core/com/jme3/scene/Node.java index 5a72496f5..e99296a2b 100644 --- a/engine/src/core/com/jme3/scene/Node.java +++ b/engine/src/core/com/jme3/scene/Node.java @@ -149,15 +149,13 @@ public class Node extends Spatial implements Savable { @Override public void updateLogicalState(float tpf){ super.updateLogicalState(tpf); - for (int i = 0, cSize = children.size(); i < cSize; i++) { + + // FIXME: Iterating through the children list backwards + // to avoid IndexOutOfBoundsException. This is sometimes unreliable, + // a more robust solution is needed. + for (int i = children.size(); i >= 0; i--){ Spatial child = children.get(i); child.updateLogicalState(tpf); - - // added this line so that nodes removed by Controls - // don't cause IndexOutOfBoundsExceptions - // FIXME: This is sometimes unreliable, a more - // robust solution is needed - cSize = children.size(); } } @@ -477,6 +475,15 @@ public class Node extends Spatial implements Savable { return children; } + /** + * Dead code + * + * @param geometry + * @param index1 + * @param index2 + * @deprecated Dead code + */ + @Deprecated public void childChange(Geometry geometry, int index1, int index2) { //just pass to parent if(parent != null) {