From 8b3a6cfbfb21a71b8efc2e3a91006712238db6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 4 Sep 2018 15:54:18 +0200 Subject: [PATCH] Update QOpenGLContext::currentContext after QPlatformOpenGLContext::makeCurrent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Laszlo Agocs --- src/gui/kernel/qopenglcontext.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp index d64d31a9e8..c5d5490ea0 100644 --- a/src/gui/kernel/qopenglcontext.cpp +++ b/src/gui/kernel/qopenglcontext.cpp @@ -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; }