From 0902e7cfd5b41d6af2302257895c960f0b730ba4 Mon Sep 17 00:00:00 2001 From: Almamu Date: Sat, 19 Apr 2025 17:40:47 +0200 Subject: [PATCH] fix: ensure variable information is not commented out by a line comment --- src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp index 74a3fb0..562c3b9 100644 --- a/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp +++ b/src/WallpaperEngine/Render/Shaders/CShaderUnit.cpp @@ -106,7 +106,13 @@ void CShaderUnit::preprocessVariables () { if (combo != std::string::npos) { this->parseComboConfiguration (line.substr(combo + strlen("// [COMBO] ")), 0); - } else if (uniform != std::string::npos && comment != std::string::npos && semicolon != std::string::npos) { + } else if ( + uniform != std::string::npos && + comment != std::string::npos && + semicolon != std::string::npos && + // this check ensures that the comment is after the semicolon (so it's not a commented-out line) + // this needs further refining as it's not taking into account block comments + semicolon < comment) { // uniforms with comments should never have a value assigned, use this fact to detect the required parts size_t last_space = line.find_last_of (' ', semicolon);