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);
|
||||
requestFocus();
|
||||
canvas.requestFocus();
|
||||
canvas.initializeCanvas();
|
||||
}
|
||||
});
|
||||
canvas.waitForCanvasCreated();
|
||||
}
|
||||
|
||||
public Rectangle syncGetBounds() {
|
||||
|
|
|
@ -48,7 +48,6 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
|||
private int width;
|
||||
private int height;
|
||||
private boolean context_update;
|
||||
private boolean canvas_created;
|
||||
private boolean dirty;
|
||||
|
||||
public void update(Graphics g) {
|
||||
|
@ -56,18 +55,22 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
|||
}
|
||||
|
||||
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 ) {
|
||||
dirty = true;
|
||||
if ( !canvas_created ) {
|
||||
setFocusTraversalKeysEnabled(false);
|
||||
/* Input methods are not enabled in fullscreen anyway, so disable always */
|
||||
enableInputMethods(false);
|
||||
addComponentListener(this);
|
||||
((MacOSXDisplay)Display.getImplementation()).setView(this);
|
||||
canvas_created = true;
|
||||
setUpdate();
|
||||
notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,18 +83,6 @@ final class MacOSXGLCanvas extends Canvas implements ComponentListener {
|
|||
return result;
|
||||
}
|
||||
|
||||
public void waitForCanvasCreated() {
|
||||
synchronized ( this ) {
|
||||
while ( !canvas_created ) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean syncShouldUpdateContext() {
|
||||
boolean should_update;
|
||||
synchronized ( this ) {
|
||||
|
|
Loading…
Reference in New Issue