From fb00d5003ac5d91953a95d8164180f8f56a2b0f2 Mon Sep 17 00:00:00 2001 From: Michael Dominic K Date: Thu, 1 Jul 2010 10:14:09 +0200 Subject: Check for EGLSurface leak only when paint device is a QGLWidget. (not QGLWindowSurface for example). Merge-request: 722 Reviewed-by: Trond --- src/opengl/qgl_egl.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/opengl/qgl_egl.cpp b/src/opengl/qgl_egl.cpp index 58d3b0a..eafa181 100644 --- a/src/opengl/qgl_egl.cpp +++ b/src/opengl/qgl_egl.cpp @@ -232,17 +232,20 @@ void QGLContextPrivate::destroyEglSurfaceForDevice() if (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: + // was created for a different winId. This applies only to QGLWidget + // paint device, so make sure this is the one we're operating on + // (as opposed to a QGLWindowSurface use case). if (paintDevice && paintDevice->devType() == QInternal::Widget) { - QGLWidget* w = static_cast(paintDevice); - - if (w->d_func()->eglSurfaceWindowId == w->winId()) - eglDestroySurface(eglContext->display(), eglSurface); - else - qWarning("WARNING: Potential EGL surface leak!"); - } else + QWidget *w = static_cast(paintDevice); + if (QGLWidget *wgl = qobject_cast(w)) { + if (wgl->d_func()->eglSurfaceWindowId != wgl->winId()) { + qWarning("WARNING: Potential EGL surface leak! Not destroying surface."); + return; + } + } + } #endif - eglDestroySurface(eglContext->display(), eglSurface); + eglDestroySurface(eglContext->display(), eglSurface); eglSurface = EGL_NO_SURFACE; } } -- cgit v0.12