[plasma/kwin] src: opengl/glshadermanager: fix a crash when shader loading fails

Xaver Hugl <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit f186d880a7f13f6c64ab041d7570be4c993b6fcc by Xaver Hugl.
Committed on 31/07/2026 at 11:46.
Pushed by zamundaaa into branch 'master'.

opengl/glshadermanager: fix a crash when shader loading fails

M  +4    -0    src/opengl/glshadermanager.cpp
M  +3    -0    src/scene/itemrenderer_opengl.cpp

https://invent.kde.org/plasma/kwin/-/commit/f186d880a7f13f6c64ab041d7570be4c993b6fcc

diff --git a/src/opengl/glshadermanager.cpp b/src/opengl/glshadermanager.cpp
index 4f3b828e950..13c3de42a28 100644
--- a/src/opengl/glshadermanager.cpp
+++ b/src/opengl/glshadermanager.cpp
@@ -152,12 +152,16 @@ bool ShaderManager::isShaderBound() const
 GLShader *ShaderManager::pushShader(ShaderTraits traits)
 {
     GLShader *shader = this->shader(traits);
+    if (!shader) {
+        return nullptr;
+    }
     pushShader(shader);
     return shader;
 }
 
 void ShaderManager::pushShader(GLShader *shader)
 {
+    Q_ASSERT(shader);
     // only bind shader if it is not already bound
     if (shader != getBoundShader()) {
         shader->bind();
diff --git a/src/scene/itemrenderer_opengl.cpp b/src/scene/itemrenderer_opengl.cpp
index cc5e741e58d..1ae619d1025 100644
--- a/src/scene/itemrenderer_opengl.cpp
+++ b/src/scene/itemrenderer_opengl.cpp
@@ -476,6 +476,9 @@ bool ItemRendererOpenGL::renderItem(const RenderTarget &renderTarget, const Rend
                 ShaderManager::instance()->popShader();
             }
             shader = ShaderManager::instance()->pushShader(traits);
+            if (!shader) {
+                continue;
+            }
             if (traits & ShaderTrait::AdjustSaturation) {
                 const auto toXYZ = renderTarget.colorDescription()->containerColorimetry().toXYZ();
                 shader->setUniform(GLShader::FloatUniform::Saturation, data.saturation());
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.