From 4cacc45d10e59bb8915b8d76c359df7a8ad0a846 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 17 Jun 2009 10:25:03 +0200 Subject: Prevented infinite recursion in GL graphics system. If creating a QGLWidget triggers the creation of a QPixmap then we might end up in an infinite recursion due to QPixmap trying to access qt_gl_share_widget(). This can happen via setWindowIcon for example. Adding an initializing flag to QGLGlobalShareWidget and preventing QGLFramebufferObject::hasOpenGLFramebufferObjects() and ::hasOpenGLFramebufferBlit() from creating a QGLWidget every time they are called with no active GL context. Reviewed-by: Trond --- src/opengl/qglframebufferobject.cpp | 6 ++---- src/opengl/qpixmapdata_gl.cpp | 7 +++++-- src/opengl/qwindowsurface_gl.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 7f229e2..eacf5bb 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -935,8 +935,7 @@ QPaintEngine *QGLFramebufferObject::paintEngine() const */ bool QGLFramebufferObject::hasOpenGLFramebufferObjects() { - if (!QGLContext::currentContext()) - QGLWidget dmy; // needed to detect and init the QGLExtensions object + QGLExtensions::init(); return (QGLExtensions::glExtensions & QGLExtensions::FramebufferObject); } @@ -1098,8 +1097,7 @@ bool QGLFramebufferObject::isBound() const */ bool QGLFramebufferObject::hasOpenGLFramebufferBlit() { - if (!QGLContext::currentContext()) - QGLWidget dmy; // needed to detect and init the QGLExtensions object + QGLExtensions::init(); return (QGLExtensions::glExtensions & QGLExtensions::FramebufferBlit); } diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 5e73ef5..f745aae 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -114,8 +114,11 @@ QGLPixmapData::~QGLPixmapData() QGLWidget *shareWidget = qt_gl_share_widget(); if (!shareWidget) return; - QGLShareContextScope ctx(shareWidget->context()); - glDeleteTextures(1, &m_textureId); + + if (m_textureId) { + QGLShareContextScope ctx(shareWidget->context()); + glDeleteTextures(1, &m_textureId); + } } bool QGLPixmapData::isValid() const diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 50d0ae7..3a7a07e 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -184,11 +184,13 @@ QGLGraphicsSystem::QGLGraphicsSystem() class QGLGlobalShareWidget { public: - QGLGlobalShareWidget() : widget(0) {} + QGLGlobalShareWidget() : widget(0), initializing(false) {} QGLWidget *shareWidget() { - if (!widget && !cleanedUp) { + if (!initializing && !widget && !cleanedUp) { + initializing = true; widget = new QGLWidget; + initializing = false; } return widget; } @@ -204,6 +206,7 @@ public: private: QGLWidget *widget; + bool initializing; }; bool QGLGlobalShareWidget::cleanedUp = false; -- cgit v0.12