aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChien Yang <[email protected]>2004-11-01 19:36:30 +0000
committerChien Yang <[email protected]>2004-11-01 19:36:30 +0000
commit4fe2e6bd4f43e427b5880cce4f4bc6b0728ef764 (patch)
tree36eabb28a37070d10f0becab41e98a5693e19f83 /src
parentc86947dfbf391e94be58b3261817d55207010c25 (diff)
Fixed issue 66 : NullPointerException in renderOffScreenBuffer.
In renderOffScreenBuffer, if in user thread case, there is a possibility that the view message has not been process yet and access to view is still invalid. Since view might not been set yet, we have to use pendingView instead. git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@66 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src')
-rw-r--r--src/classes/share/javax/media/j3d/Canvas3D.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java
index 5f351ce..943c9ad 100644
--- a/src/classes/share/javax/media/j3d/Canvas3D.java
+++ b/src/classes/share/javax/media/j3d/Canvas3D.java
@@ -1909,8 +1909,12 @@ public class Canvas3D extends Canvas {
if (!isRunning)
throw new RestrictedAccessException(J3dI18N.getString("Canvas3D11"));
- if (!active)
+ // Fix to issue 66
+ if ((!active) || (pendingView == null)) {
+ /* No rendering is performed if this Canvas3D object has not been
+ added to an active View. */
return;
+ }
// determine the offScreen boundary
// do the boundary determination here because setCanvasLocation can
@@ -1953,8 +1957,24 @@ public class Canvas3D extends Canvas {
offScreenRendering = true;
- if (view.inCanvasCallback) {
+ // Fix to issue 66.
+ /* This is an attempt to do the following check in one atomic operation :
+ ((view != null) && (view.inCanvasCallback)) */
+
+ boolean inCanvasCallback = false;
+ try {
+ inCanvasCallback = view.inCanvasCallback;
+
+ } catch (NullPointerException npe) {
+ /* Do nothing here */
+ }
+ if (inCanvasCallback) {
+ // Here we assume that view is stable if inCanvasCallback
+ // is true. This assumption is valid among all j3d threads as
+ // all access to view is synchronized by MasterControl.
+ // Issue : user threads access to view isn't synchronize hence
+ // is model will break.
if (screen.renderer == null) {
// It is possible that screen.renderer = null when this View
@@ -2028,13 +2048,14 @@ public class Canvas3D extends Canvas {
VirtualUniverse.mc.setWorkForRequestRenderer();
} else {
-
// send a message to renderBin
+ // Fix for issue 66 : Since view might not been set yet,
+ // we have to use pendingView instead.
J3dMessage createMessage = VirtualUniverse.mc.getMessage();
createMessage.threads = J3dThread.UPDATE_RENDER;
createMessage.type = J3dMessage.RENDER_OFFSCREEN;
- createMessage.universe = this.view.universe;
- createMessage.view = this.view;
+ createMessage.universe = this.pendingView.universe;
+ createMessage.view = this.pendingView;
createMessage.args[0] = this;
createMessage.args[1] = offScreenBuffer;
VirtualUniverse.mc.processMessage(createMessage);