diff options
author | Kevin Rushforth <[email protected]> | 2006-12-20 21:49:41 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2006-12-20 21:49:41 +0000 |
commit | 829409e643e1d86bcdf1bede35da824efcffa415 (patch) | |
tree | 864f6a9f9eb23a9cb8591ef6d3a4b7886758c872 | |
parent | af4b6470b766c0656260377e21b64529fbf61839 (diff) |
Fixed issue 364: Canvas3D.setOffScreenBuffer(null) sometimes hangs
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@765 ba19aa83-45c5-6ac9-afd3-db810772062c
-rw-r--r-- | src/classes/share/javax/media/j3d/Canvas3D.java | 10 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/MasterControl.java | 31 |
2 files changed, 21 insertions, 20 deletions
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java index 99b7f1a..653747d 100644 --- a/src/classes/share/javax/media/j3d/Canvas3D.java +++ b/src/classes/share/javax/media/j3d/Canvas3D.java @@ -4264,6 +4264,8 @@ public class Canvas3D extends Canvas { // Wait for off-screen buffer to be created while (offScreenBufferPending) { + // Issue 364: create master control thread if needed + VirtualUniverse.mc.createMasterControlThread(); MasterControl.threadYield(); } } @@ -4286,9 +4288,11 @@ public class Canvas3D extends Canvas { VirtualUniverse.mc.sendDestroyCtxAndOffScreenBuffer(this); // Wait for ctx and off-screen buffer to be destroyed - while (offScreenBufferPending) { - MasterControl.threadYield(); - } + while (offScreenBufferPending) { + // Issue 364: create master control thread if needed + VirtualUniverse.mc.createMasterControlThread(); + MasterControl.threadYield(); + } } private void removeCtx() { diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java index c8e6a50..fca9fe5 100644 --- a/src/classes/share/javax/media/j3d/MasterControl.java +++ b/src/classes/share/javax/media/j3d/MasterControl.java @@ -1154,6 +1154,11 @@ class MasterControl { * Create and start the MasterControl Thread. */ void createMasterControlThread() { + // Issue 364: don't create master control thread if already created + if (mcThread != null) { + return; + } + running = true; workToDo = true; state = RUNNING; @@ -2784,19 +2789,13 @@ class MasterControl { void sendDestroyCtxAndOffScreenBuffer(Canvas3D c) { // Assertion check. Look for comment in sendCreateOffScreenBuffer. GraphicsDevice gd = c.graphicsConfiguration.getDevice(); - J3dDebug.doAssert((Screen3D.deviceRendererMap.get(gd) != null), - "Screen3D.deviceRendererMap.get(gd) != null"); + assert Screen3D.deviceRendererMap.get(gd) != null; synchronized (mcThreadLock) { - // TODO KCR Issue 364: uncomment the following partial fix -// // Create the master control thread if it isn't already created -// if (mcThread == null) { -// //System.err.println("Calling createMasterControlThread()"); -// createMasterControlThread(); -// } - - // Assert the master control thread is created. - J3dDebug.doAssert((mcThread != null), "mcThread != null"); + // Issue 364: create master control thread if needed + createMasterControlThread(); + assert mcThread != null; + Renderer rdr = createRenderer(c.graphicsConfiguration); J3dMessage createMessage = new J3dMessage(); createMessage.threads = J3dThread.RENDER_THREAD; @@ -2812,7 +2811,7 @@ class MasterControl { synchronized (requestObjList) { setWorkForRequestRenderer(); pendingRequest = true; - } + } } } @@ -2833,11 +2832,9 @@ class MasterControl { "Screen3D.deviceRendererMap.get(gd) != null"); synchronized (mcThreadLock) { - // Create the master control thread if it isn't already created - if (mcThread == null) { - //System.err.println("Calling createMasterControlThread()"); - createMasterControlThread(); - } + // Create master control thread if needed + createMasterControlThread(); + assert mcThread != null; // Fix for Issue 72 : call createRenderer rather than getting // the renderer from the canvas.screen object |