From 3ba16e3923003a7919eb157ae3375792b714484e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 24 Aug 2010 13:53:49 +0200 Subject: Call eglReleaseThread() when a thread exits, and fix warnings. In Qt we track the current context in a thread via a QThreadStorage. The thread storage contents are deleted in the thread context, just before it's destroyed. This means we can safely call eglReleaseThread() in the QGLThreadContext destructor. We can then get rid of unnecessary context swaps, since we don't need to take care to reset a thread context back to 0 after having used e.g. the QGLShareContextScope mechanism, which is good. Reviewed-by: Samuel --- src/opengl/qgl.cpp | 5 +++++ src/opengl/qgl_x11egl.cpp | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 71d42a5..d9ba100 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -107,6 +107,11 @@ extern const QX11Info *qt_x11Info(const QPaintDevice *pd); #endif struct QGLThreadContext { +#ifdef QT_OPENGL_ES + ~QGLThreadContext() { + eglReleaseThread(); + } +#endif QGLContext *context; }; diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 9d28de0..1f7e60a 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -97,7 +97,6 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) XVisualInfo visualInfo; XVisualInfo *vi; int numVisuals; - EGLint id = 0; visualInfo.visualid = QEgl::getCompatibleVisualId(config); vi = XGetVisualInfo(X11->display, VisualIDMask, &visualInfo, &numVisuals); @@ -346,7 +345,7 @@ void QGLWidgetPrivate::recreateEglSurface() // old surface before re-creating a new one. Note: This should not be the case as the // surface should be deleted before the old window id. if (glcx->d_func()->eglSurface != EGL_NO_SURFACE && (currentId != eglSurfaceWindowId)) { - qWarning("EGL surface for deleted window %x was not destroyed", eglSurfaceWindowId); + qWarning("EGL surface for deleted window %lx was not destroyed", eglSurfaceWindowId); glcx->d_func()->destroyEglSurfaceForDevice(); } -- cgit v0.12