From 6ebfa59331b7febf162d05eef8316b12d559de9b Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 5 Oct 2018 14:04:09 +0100 Subject: [PATCH 1/2] [plugins/qpa] Don't crash on Qt5.12 OpengGL::makeCurrent Summary: QOpenGLContext was changed to call platform->makeCurrent before it called setCurrentContext. Because we bind window FBO and ultimately that calls QOpenGlContext::format we need Qt to know which context is current so it can tell us the format. This matches the QtWayland EGL code. BUG: 399392 Test Plan: Switched virtual desktop with the OSD (previously reliably crashed) Now it doesn't Reviewers: #kwin, zzag Reviewed By: #kwin, zzag Subscribers: zzag, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D15957 --- plugins/qpa/sharingplatformcontext.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/qpa/sharingplatformcontext.cpp b/plugins/qpa/sharingplatformcontext.cpp index 895da23b47..a318bf0795 100644 --- a/plugins/qpa/sharingplatformcontext.cpp +++ b/plugins/qpa/sharingplatformcontext.cpp @@ -26,6 +26,7 @@ along with this program. If not, see . #include #include +#include namespace KWin { @@ -48,6 +49,8 @@ SharingPlatformContext::SharingPlatformContext(QOpenGLContext *context, const EG bool SharingPlatformContext::makeCurrent(QPlatformSurface *surface) { Window *window = static_cast(surface); + + QOpenGLContextPrivate::setCurrentContext(context()); if (eglMakeCurrent(eglDisplay(), m_surface, m_surface, eglContext())) { window->bindContentFBO(); return true; From 0b7778f964107436748db020c0e4ee6f09cc6c67 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 5 Oct 2018 14:38:20 +0100 Subject: [PATCH 2/2] [plugins/qpa] Add explanatory comment --- plugins/qpa/sharingplatformcontext.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/qpa/sharingplatformcontext.cpp b/plugins/qpa/sharingplatformcontext.cpp index a318bf0795..a6e4b2bd83 100644 --- a/plugins/qpa/sharingplatformcontext.cpp +++ b/plugins/qpa/sharingplatformcontext.cpp @@ -50,6 +50,8 @@ bool SharingPlatformContext::makeCurrent(QPlatformSurface *surface) { Window *window = static_cast(surface); + // QOpenGLContext::makeCurrent in Qt5.12 calls platfrom->setContext before setCurrentContext + // but binding the content FBO looks up the format from the current context, so we need // to make sure sure Qt knows what the correct one is already QOpenGLContextPrivate::setCurrentContext(context()); if (eglMakeCurrent(eglDisplay(), m_surface, m_surface, eglContext())) { window->bindContentFBO();