path: root/src
diff options
authorLaszlo Agocs <>2014-05-22 13:38:17 +0200
committerThe Qt Project <>2014-05-23 11:39:25 +0200
commit26985092190a80c2db463f42c082c9f4792b5e66 (patch)
tree42c7c04d705911058535453aa9d815435f93ac0c /src
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 <> Reviewed-by: Jørgen Lind <>
Diffstat (limited to 'src')
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"
@@ -130,6 +131,11 @@ QSurface::QSurface(SurfaceClass type)
+#ifndef QT_NO_OPENGL
+ QOpenGLContext *context = QOpenGLContext::currentContext();
+ if (context && context->surface() == this)
+ context->doneCurrent();