From c837ffddf4c1ddf8bf890595d07a305a67380f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 10 Apr 2014 15:32:48 +0200 Subject: [PATCH] Add a cleanup() method to GLPlatform Adds a cleanup() method to GLPLatform which deletes the static instance. It gets invoked from cleanupGL() in kwinglutils on tear-down of the OpenGL backend. Thus the backend doesn't leave incorrect GL info around. E.g. if KWin starts with llvmpipe the recommended compositor is XRender. So the backend and the platform is created. Now KWin starts the XRender Compositor and the GLPlatform is still valid and when trying to load the Blur or Contrast effect this will succeed as the GLPlatform data would allow it. But on first try to use the Effect it will fail due to no valid OpenGL context and even crash. REVIEW: 117480 --- libkwineffects/kwinglplatform.cpp | 6 ++++++ libkwineffects/kwinglplatform.h | 2 ++ libkwineffects/kwinglutils.cpp | 1 + 3 files changed, 9 insertions(+) diff --git a/libkwineffects/kwinglplatform.cpp b/libkwineffects/kwinglplatform.cpp index ae2f459931..b72e355626 100644 --- a/libkwineffects/kwinglplatform.cpp +++ b/libkwineffects/kwinglplatform.cpp @@ -1053,5 +1053,11 @@ bool GLPlatform::isGLES() const #endif } +void GLPlatform::cleanup() +{ + delete s_platform; + s_platform = nullptr; +} + } // namespace KWin diff --git a/libkwineffects/kwinglplatform.h b/libkwineffects/kwinglplatform.h index 66050762a3..1001745dad 100644 --- a/libkwineffects/kwinglplatform.h +++ b/libkwineffects/kwinglplatform.h @@ -337,6 +337,8 @@ public: private: GLPlatform(); + friend void KWin::cleanupGL(); + static void cleanup(); private: QByteArray m_renderer; diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp index 881e13528f..0bf4c11e6c 100644 --- a/libkwineffects/kwinglutils.cpp +++ b/libkwineffects/kwinglutils.cpp @@ -137,6 +137,7 @@ void cleanupGL() { ShaderManager::cleanup(); GLVertexBuffer::cleanup(); + GLPlatform::cleanup(); } bool hasGLVersion(int major, int minor, int release)