From: <eli...@us...> - 2006-10-26 19:41:27
|
Revision: 2608 http://svn.sourceforge.net/java-game-lib/?rev=2608&view=rev Author: elias_naur Date: 2006-10-26 12:41:15 -0700 (Thu, 26 Oct 2006) Log Message: ----------- Don't register the Display shutdown hook in the static initializer. Register it at create() and remove it at destroy(). This avoids unnecessary conflicts when only using AWT stuff Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-10-26 15:03:47 UTC (rev 2607) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-10-26 19:41:15 UTC (rev 2608) @@ -59,6 +59,11 @@ import org.lwjgl.input.Mouse; public final class Display { + private static final Thread shutdown_hook = new Thread() { + public void run() { + reset(); + } + }; /** The display implementor */ private static final DisplayImplementation display_impl; @@ -105,16 +110,6 @@ try { current_mode = initial_mode = display_impl.init(); LWJGLUtil.log("Initial mode: " + initial_mode); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Runtime.getRuntime().addShutdownHook(new Thread() { - public void run() { - reset(); - } - }); - return null; - } - }); } catch (LWJGLException e) { throw new RuntimeException(e); } @@ -589,7 +584,10 @@ } processMessages(); + pollDevices(); + } + static void pollDevices() { // Poll the input devices while we're here if (Mouse.isCreated()) { Mouse.poll(); @@ -677,6 +675,12 @@ throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time."); if (pixel_format == null) throw new NullPointerException("pixel_format cannot be null"); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Runtime.getRuntime().addShutdownHook(shutdown_hook); + return null; + } + }); if (fullscreen) switchDisplayMode(); try { @@ -777,6 +781,12 @@ x = y = -1; cached_icons = null; reset(); + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Runtime.getRuntime().removeShutdownHook(shutdown_hook); + return null; + } + }); } private static void destroyPeerInfo() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |