Update QOpenGLContext::currentContext after QPlatformOpenGLContext::makeCurrent

Instead of doing it up front and then restoring the current context
if the makeCurrent call failed.

By delaying the update, QPlatformOpenGLContext::makeCurrent has the option
to check which context was current before the call.

Change-Id: I458f5c00d7c820acbe2f8552b0513fce99b9b683
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
bb10
Tor Arne Vestbø 2018-09-04 15:54:18 +02:00
parent 1205f4a229
commit 8b3a6cfbfb
1 changed files with 8 additions and 10 deletions

View File

@ -984,11 +984,15 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
#endif
}
QOpenGLContext *previous = QOpenGLContextPrivate::setCurrentContext(this);
if (!d->platformGLContext->makeCurrent(surface->surfaceHandle())) {
QOpenGLContextPrivate::setCurrentContext(previous);
if (!d->platformGLContext->makeCurrent(surface->surfaceHandle()))
return false;
}
QOpenGLContextPrivate::setCurrentContext(this);
#ifndef QT_NO_DEBUG
QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true);
#endif
d->surface = surface;
static bool needsWorkaroundSet = false;
static bool needsWorkaround = false;
@ -1030,14 +1034,8 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
if (needsWorkaround)
d->workaround_brokenFBOReadBack = true;
d->surface = surface;
d->shareGroup->d_func()->deletePendingResources(this);
#ifndef QT_NO_DEBUG
QOpenGLContextPrivate::toggleMakeCurrentTracker(this, true);
#endif
return true;
}