aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Rushforth <[email protected]>2008-05-15 19:11:57 +0000
committerKevin Rushforth <[email protected]>2008-05-15 19:11:57 +0000
commitfa79b5b8b0a8d2114aebfd7028330a17cb487d2d (patch)
tree5bae0abccb23581440ce716ee59b089a4baca199
parentd5347fd9eb4ae8ff4097f220bcef59bde8307b71 (diff)
Fixed issue 583: A disposed Graphics2D remains in Canvas3D after removal and addtion
Issue number: 583 Obtained from: paasiala Submitted by: kcr Reviewed by: kcr git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@898 ba19aa83-45c5-6ac9-afd3-db810772062c
-rw-r--r--src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java7
-rw-r--r--src/classes/share/javax/media/j3d/Renderer.java5
2 files changed, 11 insertions, 1 deletions
diff --git a/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java b/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java
index 381e92f..74d7ee0 100644
--- a/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java
+++ b/src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java
@@ -894,6 +894,11 @@ final class J3DGraphics2DImpl extends J3DGraphics2D {
// Issue 121 - release all resources, mark as disposed
public void dispose() {
+ // Issue 583 - do nothing if graphics has already been disposed
+ if (hasBeenDisposed) {
+ return;
+ }
+
if (Thread.currentThread() == canvas3d.screen.renderer) {
doDispose();
} else {
@@ -927,6 +932,8 @@ final class J3DGraphics2DImpl extends J3DGraphics2D {
// Mark as disposed
hasBeenDisposed = true;
+ // Issue 583 - set graphics2D field to null so it will get recreated
+ canvas3d.graphics2D = null;
}
public void drawAndFlushImage(BufferedImage img, int x, int y,
diff --git a/src/classes/share/javax/media/j3d/Renderer.java b/src/classes/share/javax/media/j3d/Renderer.java
index cf1edf9..7861f7f 100644
--- a/src/classes/share/javax/media/j3d/Renderer.java
+++ b/src/classes/share/javax/media/j3d/Renderer.java
@@ -762,7 +762,10 @@ class Renderer extends J3dThread {
(ImageObserver) ar[4]);
break;
case GraphicsContext3D.DISPOSE2D:
- canvas.graphics2D.doDispose();
+ // Issue 583 - the graphics2D field may be null here
+ if (canvas.graphics2D != null) {
+ canvas.graphics2D.doDispose();
+ }
break;
case GraphicsContext3D.SET_MODELCLIP:
canvas.graphicsContext3D.doSetModelClip(