diff options
author | Harvey Harrison <[email protected]> | 2012-01-12 19:57:01 -0800 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2012-01-12 19:57:01 -0800 |
commit | 3bd82be0371e40390abc5509cb2a7d6e3a055a12 (patch) | |
tree | e3aa0ce36b9ded320ffc00e132e21751a5a5f12a | |
parent | 75c30a94afbb8f00631e3e6be459c26ec6aefeb3 (diff) |
j3dcore: use consistent locking when updating the renderAtoms array
You cannot lock updates to a member variable using itself if the reference is
ever changed. The renderAtoms array in GeomtryAtom is resized when it does not
have enough room for all the open views. This leads to crashes similar to the following:
Exception in thread "J3D-RenderStructureUpdateThread-5" java.lang.ArrayIndexOutOfBoundsException: 3
at javax.media.j3d.GeometryAtom.getRenderAtom(GeometryAtom.java:241)
at javax.media.j3d.RenderBin.processTransformChanged(RenderBin.java:3506)
at javax.media.j3d.RenderBin.processMessages(RenderBin.java:1772)
at javax.media.j3d.StructureUpdateThread.doWork(StructureUpdateThread.java:102)
at javax.media.j3d.J3dThread.run(J3dThread.java:275)
Use the existing lockObj in this class to synchronize access. This lock is already
being used to protect updates to the centroid update calculation, but both locked
sections are relatively short, if contention ends up being a problem, renderAtoms
could be changed to an ArrayList instead which can be resized.
Signed-off-by: Harvey Harrison <[email protected]>
-rw-r--r-- | src/classes/share/javax/media/j3d/GeometryAtom.java | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/classes/share/javax/media/j3d/GeometryAtom.java b/src/classes/share/javax/media/j3d/GeometryAtom.java index ce67bd7..d49040d 100644 --- a/src/classes/share/javax/media/j3d/GeometryAtom.java +++ b/src/classes/share/javax/media/j3d/GeometryAtom.java @@ -164,7 +164,7 @@ class GeometryAtom extends Object implements BHLeafInterface, NnuId { // If renderAtom is not scoped to this view, don't even // bother creating the renderAtom - synchronized (renderAtoms) { + synchronized (lockObj) { index = view.viewIndex; if (index >= renderAtoms.length) { @@ -236,9 +236,8 @@ class GeometryAtom extends Object implements BHLeafInterface, NnuId { } } } + return (renderAtoms[index]); } - - return (renderAtoms[index]); } // If the renderAtom is transparent, then make sure that the // value is up-to-date |