From 8031c843e09b7c001fe17505c301ff012359516c Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 5 Mar 2012 15:17:50 -0800 Subject: j3dcore: use an explicit boolean when a PhysicalEnvironment has no more users Then test that boolean to determine if it needs to be removed from the Hastable. Signed-off-by: Harvey Harrison --- .../share/javax/media/j3d/MasterControl.java | 40 +++++++++++----------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/classes/share') diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java index a64c77d..f918d35 100644 --- a/src/classes/share/javax/media/j3d/MasterControl.java +++ b/src/classes/share/javax/media/j3d/MasterControl.java @@ -2051,7 +2051,6 @@ class MasterControl { // remove VirtualUniverse related threads if Universe // is empty VirtualUniverse univ = v.universe; - int i; synchronized (timeLock) { // The reason we need to sync. with timeLock is because we @@ -2079,33 +2078,34 @@ class MasterControl { } // remove all InputDeviceScheduler if this is the last View - UnorderList list = new UnorderList(1, PhysicalEnvironment.class); - for (Enumeration e = PhysicalEnvironment.physicalEnvMap.keys(); - e.hasMoreElements(); ) { + ArrayList list = new ArrayList(); + for (Enumeration e = PhysicalEnvironment.physicalEnvMap.keys(); e.hasMoreElements();) { PhysicalEnvironment phyEnv = e.nextElement(); InputDeviceScheduler sched = PhysicalEnvironment.physicalEnvMap.get(phyEnv); - for (i=phyEnv.users.size()-1; i>=0; i--) { + boolean phyEnvHasUser = false; + for (int i = 0; i < phyEnv.users.size(); i++) { if (views.contains(phyEnv.users.get(i))) { - // at least one register view refer to it. - break; + // at least one registered view refer to it. + phyEnvHasUser = true; + break; + } } - } - if (i < 0) { - if(J3dDebug.devPhase) { - J3dDebug.doDebug(J3dDebug.masterControl, J3dDebug.LEVEL_1, - "MC: Destroy InputDeviceScheduler thread " - + sched); + + if (!phyEnvHasUser) { + if (J3dDebug.devPhase) { + J3dDebug.doDebug(J3dDebug.masterControl, J3dDebug.LEVEL_1, + "MC: Destroy InputDeviceScheduler thread " + + sched); + } + sched.finish(); + phyEnv.inputsched = null; + list.add(phyEnv); } - sched.finish(); - phyEnv.inputsched = null; - list.add(phyEnv); - } } - for (i=list.size()-1; i>=0; i--) { - PhysicalEnvironment.physicalEnvMap.remove(list.get(i)); + for (int i = 0; i < list.size(); i++) { + PhysicalEnvironment.physicalEnvMap.remove(list.get(i)); } - freeContext(v); if (views.isEmpty()) { -- cgit v1.2.3