Mac OS X: Move GLCanvas init() from paint to immediately after being displayable to avoid deadlocks
This commit is contained in:
parent
1c26a5c460
commit
0c8f349653
|
@ -90,9 +90,9 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
requestFocus();
|
requestFocus();
|
||||||
canvas.requestFocus();
|
canvas.requestFocus();
|
||||||
|
canvas.initializeCanvas();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
canvas.waitForCanvasCreated();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rectangle syncGetBounds() {
|
public Rectangle syncGetBounds() {
|
||||||
|
|
|
@ -48,7 +48,6 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
private boolean context_update;
|
private boolean context_update;
|
||||||
private boolean canvas_created;
|
|
||||||
private boolean dirty;
|
private boolean dirty;
|
||||||
|
|
||||||
public void update(Graphics g) {
|
public void update(Graphics g) {
|
||||||
|
@ -56,18 +55,22 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This initializes the canvas and binds the context to it. Should only
|
||||||
|
* be called from the AWT dispatch thread.
|
||||||
|
*/
|
||||||
|
public void initializeCanvas() {
|
||||||
synchronized ( this ) {
|
synchronized ( this ) {
|
||||||
dirty = true;
|
dirty = true;
|
||||||
if ( !canvas_created ) {
|
setFocusTraversalKeysEnabled(false);
|
||||||
setFocusTraversalKeysEnabled(false);
|
/* Input methods are not enabled in fullscreen anyway, so disable always */
|
||||||
/* Input methods are not enabled in fullscreen anyway, so disable always */
|
enableInputMethods(false);
|
||||||
enableInputMethods(false);
|
addComponentListener(this);
|
||||||
addComponentListener(this);
|
((MacOSXDisplay)Display.getImplementation()).setView(this);
|
||||||
((MacOSXDisplay)Display.getImplementation()).setView(this);
|
setUpdate();
|
||||||
canvas_created = true;
|
|
||||||
setUpdate();
|
|
||||||
notify();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,18 +83,6 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitForCanvasCreated() {
|
|
||||||
synchronized ( this ) {
|
|
||||||
while ( !canvas_created ) {
|
|
||||||
try {
|
|
||||||
wait();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean syncShouldUpdateContext() {
|
public boolean syncShouldUpdateContext() {
|
||||||
boolean should_update;
|
boolean should_update;
|
||||||
synchronized ( this ) {
|
synchronized ( this ) {
|
||||||
|
|
Loading…
Reference in New Issue