summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-06-25 07:04:17 +0200
committerSven Gothel <[email protected]>2013-06-25 07:04:17 +0200
commitcc64ad2b1f7904af4e7bd27e927e0bb331db782b (patch)
tree3ac2ea6921df21bf86e2219da2ab39b74c6df007
parenta584e5dd4b40afec3cc04e1ce4abe3eb2f86e04c (diff)
NEWT WindowImpl/GLWindow: @ JVM Shutdown, force stop animation thread w/o blocking.
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java20
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java17
2 files changed, 34 insertions, 3 deletions
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index 345d92bc1..25249cee4 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -34,6 +34,8 @@
package com.jogamp.newt.opengl;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.List;
import javax.media.nativewindow.AbstractGraphicsConfiguration;
@@ -529,6 +531,24 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind
savedAnimator.resume();
}
}
+
+ @SuppressWarnings("deprecation")
+ @Override
+ public void shutdownRenderingAction() {
+ final GLAnimatorControl anim = GLWindow.this.getAnimator();
+ if ( null != anim && anim.isAnimating() ) {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run() {
+ final Thread animThread = anim.getThread();
+ if( null != animThread ) {
+ try {
+ animThread.stop();
+ } catch(Throwable t) { }
+ }
+ return null;
+ } } );
+ }
+ }
}
//----------------------------------------------------------------------
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 6787f0ab3..77ff21061 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -88,7 +88,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
ScreenImpl.initSingleton();
}
- /** Maybe utilized at a shutdown hook, impl. does not synchronize, however the Window destruction and EDT removal blocks. */
+ /** Maybe utilized at a shutdown hook, impl. does not block. */
public static final void shutdownAll() {
final int wCount = windowList.size();
if(DEBUG_IMPLEMENTATION) {
@@ -99,7 +99,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
if(DEBUG_IMPLEMENTATION) {
System.err.println("Window.shutdownAll["+(i+1)+"/"+wCount+"]: "+toHexString(w.getWindowHandle()));
}
- w.markInvalid();
+ w.shutdown();
}
}
@@ -242,7 +242,10 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
/** Fast invalidation of instance w/o any blocking function call. */
- private final void markInvalid() {
+ private final void shutdown() {
+ if(null!=lifecycleHook) {
+ lifecycleHook.shutdownRenderingAction();
+ }
setWindowHandle(0);
visible = false;
fullscreen = false;
@@ -310,6 +313,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
* @see #pauseRenderingAction()
*/
void resumeRenderingAction();
+
+ /**
+ * Shutdown rendering action (thread) abnormally.
+ * <p>
+ * Should be called only at shutdown, if necessary.
+ * </p>
+ */
+ void shutdownRenderingAction();
}
private boolean createNative() {