From 2a54ab7fe6f3979a75154a02c0c810cf6cd28033 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Thu, 1 Oct 2009 18:01:20 +0200 Subject: 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 --- src/opengl/qgl_egl.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 6c93bea..fa876c7 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(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; -- cgit v0.12