diff options
author | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-11-17 10:13:14 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@digia.com> | 2014-11-17 14:52:50 +0100 |
commit | b00d4475aafa31fef808c4b5839383b827273ddd (patch) | |
tree | afeab67bc3a24b61f6ebd7f5ca15339bce5e752c /src/widgets/kernel/qopenglwidget.cpp | |
parent | 2fb3941198f43b653cb53f53b59830c9b9856835 (diff) |
Fix broken resource cleanup in QOpenGLWidget
The context has to be made current. Otherwise we may fail to clean up or,
what's worse, we may delete FBOs and textures in some random context.
The latter was visible with ANGLE in the qopenglwidget example. When having
two QOpenGLWidget instances, the context for the second happened to be the
current one when destroying the first. This is now avoided by making sure the
correct context is current when deleting the FBOs.
Task-number: QTBUG-42696
Change-Id: I8c1eed7c13a869968cc67141e585d02c6bc6f279
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/widgets/kernel/qopenglwidget.cpp')
-rw-r--r-- | src/widgets/kernel/qopenglwidget.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/widgets/kernel/qopenglwidget.cpp b/src/widgets/kernel/qopenglwidget.cpp index 8a4e0c8ffd..eee4aa546c 100644 --- a/src/widgets/kernel/qopenglwidget.cpp +++ b/src/widgets/kernel/qopenglwidget.cpp @@ -578,12 +578,22 @@ GLuint QOpenGLWidgetPrivate::textureId() const void QOpenGLWidgetPrivate::reset() { + Q_Q(QOpenGLWidget); + + // Destroy the OpenGL resources first. These need the context to be current. + if (initialized) + q->makeCurrent(); + delete paintDevice; paintDevice = 0; delete fbo; fbo = 0; delete resolvedFbo; resolvedFbo = 0; + + if (initialized) + q->doneCurrent(); + // Delete the context first, then the surface. Slots connected to // the context's aboutToBeDestroyed() may still call makeCurrent() // to perform some cleanup. |