diff options
author | Harvey Harrison <[email protected]> | 2012-03-05 15:17:50 -0800 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2012-03-05 15:20:07 -0800 |
commit | 8031c843e09b7c001fe17505c301ff012359516c (patch) | |
tree | 8871a6d207806bfa3525e4a708847ea24f1317d3 /src/classes/share | |
parent | 3470738aa142bbc0330ed16f543f80ad4e75bfda (diff) |
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 <[email protected]>
Diffstat (limited to 'src/classes/share')
-rw-r--r-- | src/classes/share/javax/media/j3d/MasterControl.java | 40 |
1 files changed, 20 insertions, 20 deletions
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<PhysicalEnvironment> e = PhysicalEnvironment.physicalEnvMap.keys(); - e.hasMoreElements(); ) { + ArrayList<PhysicalEnvironment> list = new ArrayList<PhysicalEnvironment>(); + for (Enumeration<PhysicalEnvironment> 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()) { |