Skip to content

Commit efc1962

Browse files
authored
Merge pull request #1320 from MeFisto94/fix-lwjgl3-double-stop
Fixes #1319 - LWJGL2: start(true) should not freeze when context could not be initialized
2 parents 989b2a6 + d19ae58 commit efc1962

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglAbstractDisplay.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ public abstract class LwjglAbstractDisplay extends LwjglContext implements Runna
9393
/**
9494
* Does LWJGL display initialization in the OpenGL thread
9595
*/
96-
protected boolean initInThread(){
96+
protected boolean initInThread() {
9797
try {
98-
if (!JmeSystem.isLowPermissions()){
98+
if (!JmeSystem.isLowPermissions()) {
9999
// Enable uncaught exception handler only for current thread
100100
Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
101101
@Override
102102
public void uncaughtException(Thread thread, Throwable thrown) {
103103
listener.handleError("Uncaught exception thrown in "+thread.toString(), thrown);
104-
if (needClose.get()){
104+
if (needClose.get()) {
105105
// listener.handleError() has requested the
106106
// context to close. Satisfy request.
107107
deinitInThread();
@@ -119,23 +119,25 @@ public void uncaughtException(Thread thread, Throwable thrown) {
119119

120120
created.set(true);
121121
super.internalCreate();
122-
} catch (Exception ex){
122+
} catch (Exception ex) {
123123
try {
124-
if (Display.isCreated())
124+
if (Display.isCreated()) {
125125
Display.destroy();
126+
}
126127
} catch (Exception ex2){
127128
logger.log(Level.WARNING, null, ex2);
128129
}
129130

130131
listener.handleError("Failed to create display", ex);
132+
createdLock.notifyAll(); // Release the lock, so start(true) doesn't deadlock.
131133
return false; // if we failed to create display, do not continue
132134
}
133135

134136
listener.initialize();
135137
return true;
136138
}
137139

138-
protected boolean checkGLError(){
140+
protected boolean checkGLError() {
139141
try {
140142
Util.checkGLError();
141143
} catch (OpenGLException ex){

0 commit comments

Comments
 (0)