diff options
author | Trond Kjernåsen <trond.kjernasen@nokia.com> | 2010-06-11 12:47:21 (GMT) |
---|---|---|
committer | Trond Kjernåsen <trond.kjernasen@nokia.com> | 2010-06-11 12:55:34 (GMT) |
commit | cde3f39cb75ba69185cca8176ea7126f8441f042 (patch) | |
tree | aafc9a816ce6a55e4ad6ba999d2a6d2d8e4be1f1 /src/opengl | |
parent | 9a16161889c7f6c15c4d5679148a28fe51f95abb (diff) | |
download | Qt-cde3f39cb75ba69185cca8176ea7126f8441f042.zip Qt-cde3f39cb75ba69185cca8176ea7126f8441f042.tar.gz Qt-cde3f39cb75ba69185cca8176ea7126f8441f042.tar.bz2 |
Fixed an on-exit crash for apps using GL.
If a QGLWidget is left on the heap when the QApplication destructor is
called, it will leave the QGLWidget in a broken state.
The widget itself is released and set to a non-created state,
which the associated QGLContext doesn't get notified about.
With this patch the QGLWidget knows when QWidget::destroy() is called
and can act acordingly.
Task-number: QT-3498, QTBUG-10995
Reviewed-by: Paul
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/qgl.cpp | 2 | ||||
-rw-r--r-- | src/opengl/qgl_p.h | 4 | ||||
-rw-r--r-- | src/opengl/qgl_x11.cpp | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 5c5d3d1..b4c85ac 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -3674,8 +3674,10 @@ QGLWidget::~QGLWidget() bool doRelease = (glcx && glcx->windowCreated()); #endif delete d->glcx; + d->glcx = 0; #if defined(Q_WGL) delete d->olcx; + d->olcx = 0; #endif #if defined(GLX_MESA_release_buffers) && defined(QGL_USE_MESA_EXT) if (doRelease) diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 16c225f..1727a41 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -177,6 +177,10 @@ public: void initContext(QGLContext *context, const QGLWidget* shareWidget); bool renderCxPm(QPixmap *pixmap); void cleanupColormaps(); + void aboutToDestroy() { + if (glcx) + glcx->reset(); + } QGLContext *glcx; QGLWidgetGLPaintDevice glDevice; diff --git a/src/opengl/qgl_x11.cpp b/src/opengl/qgl_x11.cpp index da072c7..bfb232d 100644 --- a/src/opengl/qgl_x11.cpp +++ b/src/opengl/qgl_x11.cpp @@ -928,7 +928,7 @@ void QGLContext::makeCurrent() } else if (d->paintDevice->devType() == QInternal::Pbuffer) { ok = glXMakeCurrent(xinfo->display(), (GLXPbuffer)d->pbuf, (GLXContext)d->cx); } else if (d->paintDevice->devType() == QInternal::Widget) { - ok = glXMakeCurrent(xinfo->display(), ((QWidget *)d->paintDevice)->winId(), (GLXContext)d->cx); + ok = glXMakeCurrent(xinfo->display(), ((QWidget *)d->paintDevice)->internalWinId(), (GLXContext)d->cx); } if (!ok) qWarning("QGLContext::makeCurrent(): Failed."); |