summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl_mac.mm
diff options
context:
space:
mode:
authorMorten Engvoldsen <morten.engvoldsen@nokia.com>2010-09-03 06:54:51 (GMT)
committerMorten Engvoldsen <morten.engvoldsen@nokia.com>2010-09-03 06:54:51 (GMT)
commite7935dc46fcc062b28cc3aa385f389fa3842b190 (patch)
tree1559e188c8a4f3f149d5880e52f31ee996f4be2b /src/opengl/qgl_mac.mm
parent54796e0d3150df7dd94e715c095c21fb227139ee (diff)
parentfc4d386f2cc8984b98957d83d8cdb57c1105890f (diff)
downloadQt-e7935dc46fcc062b28cc3aa385f389fa3842b190.zip
Qt-e7935dc46fcc062b28cc3aa385f389fa3842b190.tar.gz
Qt-e7935dc46fcc062b28cc3aa385f389fa3842b190.tar.bz2
Merge commit 'staging-1/4.7' into doc-4.7
Diffstat (limited to 'src/opengl/qgl_mac.mm')
-rw-r--r--src/opengl/qgl_mac.mm14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm
index 66fe7d3..f023a97 100644
--- a/src/opengl/qgl_mac.mm
+++ b/src/opengl/qgl_mac.mm
@@ -697,9 +697,17 @@ void QGLContext::updatePaintDevice()
QWidget *w = (QWidget *)d->paintDevice;
NSView *view = qt_mac_nativeview_for(w);
- // ideally we would use QWidget::isVisible(), but we get "invalid drawable" errors
- if (![(NSWindow *)qt_mac_window_for(w) isVisible])
- return;
+ // Trying to attach the GL context to the NSView will fail with
+ // "invalid drawable" if done too soon, but we have to make sure
+ // the connection is made before the first paint event. Using
+ // the NSView do to this check fails as the NSView is visible
+ // before it's safe to connect, and using the NSWindow fails as
+ // the NSWindow will become visible after the first paint event.
+ // This leaves us with the QWidget, who's visible state seems
+ // to match the point in time when it's safe to connect.
+ if (!w || !w->isVisible())
+ return; // Not safe to attach GL context to view yet
+
if ([static_cast<NSOpenGLContext *>(d->cx) view] != view && ![view isHidden])
[static_cast<NSOpenGLContext *>(d->cx) setView:view];
} else if (d->paintDevice->devType() == QInternal::Pixmap) {