diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-25 18:01:08 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-25 18:14:01 +0300 |
commit | 1bec2aa54e85f4b7aceab98aee705516e4a96e1c (patch) | |
tree | a88e362d48e81d064d9fa4f80b7a324021c559e3 | |
parent | 485ea4353f293317ce395a75663758092cb6f969 (diff) |
Cycles: Fix crash in constant folding introduced by recent commit
Graph::disconnect() actually modifies links, needs to create a copy to iterate
if disconnect happens form inside the loop.
Question tho whether we can control this somehow..
Reported by BzztPloink in IRC, thanks!
-rw-r--r-- | intern/cycles/render/graph.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 8468690841d..2977555b410 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -582,12 +582,13 @@ void ShaderGraph::constant_fold(set<ShaderNode*>& done, ShaderNode *node) } /* Then fold self. */ - foreach(ShaderOutput *sock, node->outputs) { + foreach(ShaderOutput *output, node->outputs) { float3 optimized_value = make_float3(0.0f, 0.0f, 0.0f); - if(node->constant_fold(sock, &optimized_value)) { - /* Apply optimized value to connected sockets */ - foreach(ShaderInput *in, sock->links) { + if(node->constant_fold(output, &optimized_value)) { + /* Apply optimized value to connected sockets. */ + vector<ShaderInput*> links(output->links); + foreach(ShaderInput *in, links) { in->value = optimized_value; disconnect(in); } |