From e99a9ff495d90e3d97615c8f283cc6d71514035c Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 8 Jun 2021 16:56:34 +0200 Subject: [PATCH] windows: gl: Print GetLastError() when makeCurrent fails This matches the behavior of other implementations, such as QEGLPlatformContext: doing a qWarning with the relevant error from eglGetError() or equivalent is helpful when something goes wrong and should be common among QOpenGLPlatformContext implementations. Task-number: QTBUG-85714 Change-Id: Ifa5d22b83808c92ae92efcbcddc8d8c3d3ba34b1 Reviewed-by: Friedemann Kleint (cherry picked from commit 03650696a1fb727a337865d43f068ddc7723a893) Reviewed-by: Qt Cherry-pick Bot --- src/plugins/platforms/windows/qwindowsglcontext.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp index 8c41cc135d2..1a7be0d2716 100644 --- a/src/plugins/platforms/windows/qwindowsglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp @@ -1301,7 +1301,10 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface) && QOpenGLStaticContext::opengl32.wglGetCurrentDC() == contextData->hdc) { return true; } - return QOpenGLStaticContext::opengl32.wglMakeCurrent(contextData->hdc, contextData->renderingContext); + const bool success = QOpenGLStaticContext::opengl32.wglMakeCurrent(contextData->hdc, contextData->renderingContext); + if (!success) + qErrnoWarning("%s: wglMakeCurrent() failed for existing context data", __FUNCTION__); + return success; } // Create a new entry. const QOpenGLContextData newContext(m_renderingContext, hwnd, GetDC(hwnd)); @@ -1329,6 +1332,8 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface) qCDebug(lcQpaGl) << "makeCurrent(): context loss detected" << this; // Drop the surface. Will recreate on the next makeCurrent. window->invalidateSurface(); + } else { + qErrnoWarning("%s: wglMakeCurrent() failed", __FUNCTION__); } }