From fa79b5b8b0a8d2114aebfd7028330a17cb487d2d Mon Sep 17 00:00:00 2001 From: Kevin Rushforth Date: Thu, 15 May 2008 19:11:57 +0000 Subject: 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 --- src/classes/share/javax/media/j3d/J3DGraphics2DImpl.java | 7 +++++++ src/classes/share/javax/media/j3d/Renderer.java | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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( -- cgit v1.2.3