Display: Don't add the shutdown hook twice when a previous create() call has failed
This commit is contained in:
parent
a7e564a06a
commit
7ca70d8c5e
|
@ -657,6 +657,24 @@ public final class Display {
|
||||||
create(pixel_format, null);
|
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
|
* 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
|
* context are not supported on the platform, the display mode will be switched to the mode returned by
|
||||||
|
@ -675,12 +693,8 @@ public final class Display {
|
||||||
throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time.");
|
throw new IllegalStateException("Only one LWJGL context may be instantiated at any one time.");
|
||||||
if (pixel_format == null)
|
if (pixel_format == null)
|
||||||
throw new NullPointerException("pixel_format cannot be null");
|
throw new NullPointerException("pixel_format cannot be null");
|
||||||
AccessController.doPrivileged(new PrivilegedAction() {
|
removeShutdownHook();
|
||||||
public Object run() {
|
registerShutdownHook();
|
||||||
Runtime.getRuntime().addShutdownHook(shutdown_hook);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
switchDisplayMode();
|
switchDisplayMode();
|
||||||
try {
|
try {
|
||||||
|
@ -781,12 +795,7 @@ public final class Display {
|
||||||
x = y = -1;
|
x = y = -1;
|
||||||
cached_icons = null;
|
cached_icons = null;
|
||||||
reset();
|
reset();
|
||||||
AccessController.doPrivileged(new PrivilegedAction() {
|
removeShutdownHook();
|
||||||
public Object run() {
|
|
||||||
Runtime.getRuntime().removeShutdownHook(shutdown_hook);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void destroyPeerInfo() {
|
private static void destroyPeerInfo() {
|
||||||
|
|
Loading…
Reference in New Issue