From: <eli...@us...> - 2006-11-19 11:43:03
|
Revision: 2660 http://svn.sourceforge.net/java-game-lib/?rev=2660&view=rev Author: elias_naur Date: 2006-11-19 03:43:00 -0800 (Sun, 19 Nov 2006) Log Message: ----------- Display: Don't add the shutdown hook twice when a previous create() call has failed 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-11-19 09:08:26 UTC (rev 2659) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-11-19 11:43:00 UTC (rev 2660) @@ -657,6 +657,24 @@ create(pixel_format, null); } + private static void removeShutdownHook() { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Runtime.getRuntime().removeShutdownHook(shutdown_hook); + return null; + } + }); + } + + private static void registerShutdownHook() { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + Runtime.getRuntime().addShutdownHook(shutdown_hook); + return null; + } + }); + } + /** * Create the OpenGL context with the given minimum parameters. If isFullscreen() is true or if windowed * context are not supported on the platform, the display mode will be switched to the mode returned by @@ -675,12 +693,8 @@ 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; - } - }); + removeShutdownHook(); + registerShutdownHook(); if (fullscreen) switchDisplayMode(); try { @@ -781,12 +795,7 @@ x = y = -1; cached_icons = null; reset(); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Runtime.getRuntime().removeShutdownHook(shutdown_hook); - return null; - } - }); + removeShutdownHook(); } private static void destroyPeerInfo() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |