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>
This commit is contained in:
Laszlo Agocs 2014-05-22 13:38:17 +02:00 committed by The Qt Project
parent 05e8b54d23
commit 2698509219

View File

@ -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
}
/*!