summaryrefslogtreecommitdiff
path: root/src/opengl/qgl_egl.cpp
diff options
context:
space:
mode:
authorTom Cooksey <thomas.cooksey@nokia.com>2009-10-01 18:01:20 +0200
committerTom Cooksey <thomas.cooksey@nokia.com>2009-10-01 18:13:02 +0200
commit2a54ab7fe6f3979a75154a02c0c810cf6cd28033 (patch)
treeb4d565248a404fcf1fa76f147d9095bdc8a5c05c /src/opengl/qgl_egl.cpp
parented6a2701320db60dd256df61a8030a867b917302 (diff)
downloadqt4-tools-2a54ab7fe6f3979a75154a02c0c810cf6cd28033.tar.gz
Fix BadDrawable errors when re-parenting a QGLWidget on X11/EGL
It's actually not really reparenting, but calling setWindowFlags which triggered the errors. But setWindowFlags causes a re-parent. The context isn't really the right please to free the surface, but fixing that is a much more intrusive change. Reviewed-By: TrustMe
Diffstat (limited to 'src/opengl/qgl_egl.cpp')
-rw-r--r--src/opengl/qgl_egl.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp
index 6c93beaf3e..fa876c7972 100644
--- a/src/opengl/qgl_egl.cpp
+++ b/src/opengl/qgl_egl.cpp
@@ -142,8 +142,19 @@ void QGLContext::reset()
d->cleanup();
doneCurrent();
if (d->eglContext) {
- if (d->eglSurface != EGL_NO_SURFACE)
- eglDestroySurface(d->eglContext->display(), d->eglSurface);
+ if (d->eglSurface != EGL_NO_SURFACE) {
+#ifdef Q_WS_X11
+ // Make sure we don't call eglDestroySurface on a surface which
+ // was created for a different winId:
+ if (d->paintDevice->devType() == QInternal::Widget) {
+ QGLWidget* w = static_cast<QGLWidget*>(d->paintDevice);
+
+ if (w->d_func()->eglSurfaceWindowId == w->winId())
+ eglDestroySurface(d->eglContext->display(), d->eglSurface);
+ } else
+#endif
+ eglDestroySurface(d->eglContext->display(), d->eglSurface);
+ }
delete d->eglContext;
}
d->eglContext = 0;