Mac OS X: Move GLCanvas init() from paint to immediately after being displayable to avoid deadlocks

This commit is contained in:
Elias Naur 2005-01-21 08:35:35 +00:00
parent 1c26a5c460
commit 0c8f349653
2 changed files with 15 additions and 24 deletions

View File

@ -90,9 +90,9 @@ final class MacOSXFrame extends Frame implements WindowListener, ComponentListen
setVisible(true);
requestFocus();
canvas.requestFocus();
canvas.initializeCanvas();
}
});
canvas.waitForCanvasCreated();
}
public Rectangle syncGetBounds() {

View File

@ -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();
}
setFocusTraversalKeysEnabled(false);
/* Input methods are not enabled in fullscreen anyway, so disable always */
enableInputMethods(false);
addComponentListener(this);
((MacOSXDisplay)Display.getImplementation()).setView(this);
setUpdate();
}
}
@ -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 ) {