From 2b9b9a38e7273f640b6d1f3e174e8204cf7d81dd Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 19 Jul 2016 14:56:06 +0100 Subject: QOpenGLVertexArrayObject: clean up the destructor Calling QOpenGLContext::surface() on a non-current context will likely return NULL, so the code path that tried to reset the old context as current would actually fail. Change-Id: Ibbc8da877740a596aa7dd0af8ccffb9a1877290a Reviewed-by: Sean Harmer --- src/gui/opengl/qopenglvertexarrayobject.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/gui/opengl') diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index 2a1b7f4bf4..33c38519cc 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -352,9 +352,11 @@ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() Q_D(QOpenGLVertexArrayObject); QOpenGLContext *oldContext = 0; + QSurface *oldContextSurface = 0; QScopedPointer offscreenSurface; if (d->context && ctx && d->context != ctx) { oldContext = ctx; + oldContextSurface = ctx->surface(); // Cannot just make the current surface current again with another context. // The format may be incompatible and some platforms (iOS) may impose // restrictions on using a window with different contexts. Create an @@ -374,7 +376,7 @@ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() destroy(); if (oldContext) { - if (!oldContext->makeCurrent(oldContext->surface())) + if (!oldContext->makeCurrent(oldContextSurface)) qWarning("QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() failed to restore current context"); } } -- cgit v1.2.3