From 216530730b56aae165d5fd08468c06fb7ab8dd08 Mon Sep 17 00:00:00 2001 From: Kevin Rushforth Date: Tue, 7 Nov 2006 22:02:04 +0000 Subject: Fixed issue 84: Rendering pauses after Canvas3D disposal until AWT event This also supersedes the fix for the previously-reported JCanvas3D freeze (issue 131), and is a more robust solution. git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@742 ba19aa83-45c5-6ac9-afd3-db810772062c --- src/classes/share/javax/media/j3d/Canvas3D.java | 32 ++++++++++++---------- .../share/javax/media/j3d/MasterControl.java | 10 +++++-- 2 files changed, 25 insertions(+), 17 deletions(-) (limited to 'src/classes') diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java index f617565..dd35eec 100644 --- a/src/classes/share/javax/media/j3d/Canvas3D.java +++ b/src/classes/share/javax/media/j3d/Canvas3D.java @@ -1309,21 +1309,21 @@ public class Canvas3D extends Canvas { } - if (rdr != null) { - rdr.userStop = false; - } ctxTimeStamp = 0; if ((view != null) && (view.universe != null)) { view.universe.checkForEnableEvents(); } - // Issue 131: Call redraw() if this is an auto-off-screen Canvas3D, - // so it will start up correctly. It isn't necessary to do this for - // on-screen Canvas3Ds because redraw() will be called when we - // get the first paint(). - if (offScreen) { - redraw(); - } + if (rdr != null) { + // Issue 84: Send a message to MC to restart renderer + // Note that this also obviates the need for the earlier fix to + // issue 131 which called redraw() for auto-off-screen Canvas3Ds + // (and this is a more robust fix) + VirtualUniverse.mc.postRequest(MasterControl.START_RENDERER, rdr); + while (rdr.userStop) { + MasterControl.threadYield(); + } + } } // When this canvas is removed a frame, this notification gets called. We @@ -1379,7 +1379,7 @@ public class Canvas3D extends Canvas { visible = false; screen.removeUser(this); - evaluateActive(); + evaluateActive(); VirtualUniverse.mc.freeCanvasId(canvasId); canvasBit = 0; @@ -1393,7 +1393,7 @@ public class Canvas3D extends Canvas { // it will free graphics2D textureID graphics2D = null; - super.removeNotify(); + super.removeNotify(); // This may happen if user explicity call this before // addNotify() @@ -1438,9 +1438,13 @@ public class Canvas3D extends Canvas { added = false; if (rdr != null) { - rdr.userStop = false; + // Issue 84: Send a message to MC to restart renderer + VirtualUniverse.mc.postRequest(MasterControl.START_RENDERER, rdr); + while (rdr.userStop) { + MasterControl.threadYield(); + } } - + // Fix for issue 102 removing strong reference and avoiding memory leak // due retention of parent container diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java index 89967fc..c8e6a50 100644 --- a/src/classes/share/javax/media/j3d/MasterControl.java +++ b/src/classes/share/javax/media/j3d/MasterControl.java @@ -2986,9 +2986,13 @@ class MasterControl { threadListsChanged = true; } } else if (type == START_RENDERER) { - Canvas3D c3d = (Canvas3D) o; - if (!c3d.isFatalError()) { - c3d.isRunningStatus = true; + if (o instanceof Canvas3D) { + Canvas3D c3d = (Canvas3D) o; + if (!c3d.isFatalError()) { + c3d.isRunningStatus = true; + } + } else { + ((Renderer) o).userStop = false; } threadListsChanged = true; } else if (type == STOP_RENDERER) { -- cgit v1.2.3