From 8909f8780b007569f92d5f8715376c0ad23ba9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 26 Aug 2016 07:32:34 +0200 Subject: [PATCH] [plugins/qpa] Call makeCurrent on the QOpenGLContext instead of the one in the platform context Summary: SharingPlatformContext::swapBuffers needs to make the context current. For this is calls makeCurrent. Later on this tries to bind a fbo, which checks calls into the current QOpenGLContext. As we called makeCurrent on our own platform context Qt doesn't know that the context is current and returns in the worst case a nullptr and crashes. This change calls makeCurrent on the QOpenGLContext so that Qt also knows that this context is current now. The QOpenGLContext calls makeCurrent on the platform context, so what our code tried to do is still being done. In addition the method context() in AbstractPlatformContext is renamed to eglContext to no longer shadow the method in QPlatformContext. Reviewers: #kwin, #plasma_on_wayland Subscribers: plasma-devel, kwin Tags: #plasma_on_wayland, #kwin Differential Revision: https://phabricator.kde.org/D2582 --- plugins/qpa/abstractplatformcontext.h | 2 +- plugins/qpa/platformcontextwayland.cpp | 2 +- plugins/qpa/sharingplatformcontext.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/qpa/abstractplatformcontext.h b/plugins/qpa/abstractplatformcontext.h index fda34d4c18..c32c62b364 100644 --- a/plugins/qpa/abstractplatformcontext.h +++ b/plugins/qpa/abstractplatformcontext.h @@ -53,7 +53,7 @@ protected: return m_config; } bool bindApi(); - EGLContext context() const { + EGLContext eglContext() const { return m_context; } void createContext(EGLContext shareContext = EGL_NO_CONTEXT); diff --git a/plugins/qpa/platformcontextwayland.cpp b/plugins/qpa/platformcontextwayland.cpp index aacad703ea..f43ae9f792 100644 --- a/plugins/qpa/platformcontextwayland.cpp +++ b/plugins/qpa/platformcontextwayland.cpp @@ -44,7 +44,7 @@ bool PlatformContextWayland::makeCurrent(QPlatformSurface *surface) return false; } } - return eglMakeCurrent(eglDisplay(), s, s, context()); + return eglMakeCurrent(eglDisplay(), s, s, eglContext()); } bool PlatformContextWayland::isSharing() const diff --git a/plugins/qpa/sharingplatformcontext.cpp b/plugins/qpa/sharingplatformcontext.cpp index 1e5a788df1..681093daa4 100644 --- a/plugins/qpa/sharingplatformcontext.cpp +++ b/plugins/qpa/sharingplatformcontext.cpp @@ -48,7 +48,7 @@ SharingPlatformContext::SharingPlatformContext(QOpenGLContext *context, Integrat bool SharingPlatformContext::makeCurrent(QPlatformSurface *surface) { Window *window = static_cast(surface); - if (eglMakeCurrent(eglDisplay(), m_surface, m_surface, context())) { + if (eglMakeCurrent(eglDisplay(), m_surface, m_surface, eglContext())) { window->bindContentFBO(); return true; } @@ -74,7 +74,7 @@ void SharingPlatformContext::swapBuffers(QPlatformSurface *surface) qCDebug(KWIN_QPA) << "SwapBuffers called but there is no ShellClient"; return; } - makeCurrent(surface); + context()->makeCurrent(surface->surface()); glFlush(); c->setInternalFramebufferObject(window->swapFBO()); window->bindContentFBO();