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 <sean.harmer@kdab.com>
This commit is contained in:
parent
e6034a4740
commit
2b9b9a38e7
@ -352,9 +352,11 @@ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject()
|
||||
|
||||
Q_D(QOpenGLVertexArrayObject);
|
||||
QOpenGLContext *oldContext = 0;
|
||||
QSurface *oldContextSurface = 0;
|
||||
QScopedPointer<QOffscreenSurface> 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");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user