summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qsurface.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-05-22 13:38:17 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-23 11:39:25 +0200
commit26985092190a80c2db463f42c082c9f4792b5e66 (patch)
tree42c7c04d705911058535453aa9d815435f93ac0c /src/gui/kernel/qsurface.cpp
parent05e8b54d23e3d906d5f29113a73d88d3482c8f64 (diff)
Call doneCurrent on QOpenGLContext when the surface dies
Doing makeCurrent() followed by destroying the surface (and no doneCurrent) results in still having the pointer stored internally in the QOpenGLContext. If then a function like defaultFramebufferObject() is called, the pointer is dereferenced. To fix this, the doneCurrent() has to be called when the surface is destroyed before the context without doneCurrent(). This is pretty much what the user would expect anyhow. Task-number: QTBUG-38994 Change-Id: Ibd4083d9291c7fd39b38ce81a988a8e0c9d55d60 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
Diffstat (limited to 'src/gui/kernel/qsurface.cpp')
-rw-r--r--src/gui/kernel/qsurface.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp
index a27bdaccde..e7fd2f79a4 100644
--- a/src/gui/kernel/qsurface.cpp
+++ b/src/gui/kernel/qsurface.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qsurface.h"
+#include "qopenglcontext.h"
QT_BEGIN_NAMESPACE
@@ -130,6 +131,11 @@ QSurface::QSurface(SurfaceClass type)
*/
QSurface::~QSurface()
{
+#ifndef QT_NO_OPENGL
+ QOpenGLContext *context = QOpenGLContext::currentContext();
+ if (context && context->surface() == this)
+ context->doneCurrent();
+#endif
}
/*!