From 26985092190a80c2db463f42c082c9f4792b5e66 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 22 May 2014 13:38:17 +0200 Subject: Call doneCurrent on QOpenGLContext when the surface dies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/gui/kernel/qsurface.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') 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 } /*! -- cgit v1.2.3