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
This commit is contained in:
Martin Gräßlin 2014-04-10 15:32:48 +02:00
parent 09d421fbb4
commit c837ffddf4
3 changed files with 9 additions and 0 deletions

View file

@ -1053,5 +1053,11 @@ bool GLPlatform::isGLES() const
#endif
}
void GLPlatform::cleanup()
{
delete s_platform;
s_platform = nullptr;
}
} // namespace KWin

View file

@ -337,6 +337,8 @@ public:
private:
GLPlatform();
friend void KWin::cleanupGL();
static void cleanup();
private:
QByteArray m_renderer;

View file

@ -137,6 +137,7 @@ void cleanupGL()
{
ShaderManager::cleanup();
GLVertexBuffer::cleanup();
GLPlatform::cleanup();
}
bool hasGLVersion(int major, int minor, int release)