From 3ad56045805b50ade252e4353eac158e7eee7b5f Mon Sep 17 00:00:00 2001 From: Vlad Zagorodniy Date: Sun, 2 Dec 2018 13:59:45 +0200 Subject: [PATCH] [scenes/opengl] Cleanup cached decoration shadow textures when suspending compositing Summary: When suspending compositing, SceneOpenGLShadow cannot cleanup cached decoration shadow textures because the effects handler is already gone. This sometimes can result in a crash when running kwin_x11 --replace (we're hitting an assert statement). To fix that, let's use the scene instead of the effects handler for making the OpenGL context current. Test Plan: No longer hit the assert statement: ASSERT: "m_cache.isEmpty()" in file /home/vlad/Workspace/KDE/src/kde/workspace/kwin/plugins/scenes/opengl/scene_opengl.cpp, line 2025 Application::crashHandler() called with signal 6; recent crashes: 1 QCoreApplication::applicationFilePath: Please instantiate the QApplication object first KCrash: crashing... crashRecursionCounter = 2 KCrash: Application Name = kwin_x11 path = /home/vlad/Workspace/KDE/usr/bin pid = 5407 KCrash: Arguments: /home/vlad/Workspace/KDE/usr/bin/kwin_x11 --replace Reviewers: #kwin, graesslin Reviewed By: #kwin, graesslin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D17306 --- plugins/scenes/opengl/scene_opengl.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp index 8886fb0d74..49574e79b4 100644 --- a/plugins/scenes/opengl/scene_opengl.cpp +++ b/plugins/scenes/opengl/scene_opengl.cpp @@ -2074,8 +2074,9 @@ SceneOpenGLShadow::SceneOpenGLShadow(Toplevel *toplevel) SceneOpenGLShadow::~SceneOpenGLShadow() { - if (effects) { - effects->makeOpenGLContextCurrent(); + Scene *scene = Compositor::self()->scene(); + if (scene) { + scene->makeOpenGLContextCurrent(); DecorationShadowTextureCache::instance().unregister(this); m_texture.reset(); } @@ -2334,7 +2335,8 @@ bool SceneOpenGLShadow::prepareBackend() { if (hasDecorationShadow()) { // simplifies a lot by going directly to - effects->makeOpenGLContextCurrent(); + Scene *scene = Compositor::self()->scene(); + scene->makeOpenGLContextCurrent(); m_texture = DecorationShadowTextureCache::instance().getTexture(this); return true; @@ -2403,7 +2405,8 @@ bool SceneOpenGLShadow::prepareBackend() } } - effects->makeOpenGLContextCurrent(); + Scene *scene = Compositor::self()->scene(); + scene->makeOpenGLContextCurrent(); m_texture = QSharedPointer::create(image); if (m_texture->internalFormat() == GL_R8) {