diff --git a/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh b/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh index 7a0e9a9b300..9f812e2ba72 100644 --- a/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh +++ b/source/blender/gpu/glsl_preprocess/glsl_preprocess.hh @@ -946,8 +946,6 @@ class Preprocessor { const string suffix = match.suffix().str(); out_str += prefix; - /** IMPORTANT: `match` is invalid after the assignment. */ - next_str = definition + suffix; /* Assert definition doesn't contain any side effect. */ if (value.find("++") != string::npos || value.find("--") != string::npos) { @@ -1017,6 +1015,9 @@ class Preprocessor { modified = regex_replace( modified, regex(R"(([^\.])\b)" + name + R"(\b([^(]))"), "$1" + value + "$2"); + /** IMPORTANT: `match` is invalid after the assignment. */ + next_str = definition + suffix; + /* Replace whole modified scope in output string. */ replace_all(next_str, original, modified); }