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!
This commit is contained in:
@@ -582,12 +582,13 @@ void ShaderGraph::constant_fold(set<ShaderNode*>& done, ShaderNode *node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Then fold self. */
|
/* Then fold self. */
|
||||||
foreach(ShaderOutput *sock, node->outputs) {
|
foreach(ShaderOutput *output, node->outputs) {
|
||||||
float3 optimized_value = make_float3(0.0f, 0.0f, 0.0f);
|
float3 optimized_value = make_float3(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
if(node->constant_fold(sock, &optimized_value)) {
|
if(node->constant_fold(output, &optimized_value)) {
|
||||||
/* Apply optimized value to connected sockets */
|
/* Apply optimized value to connected sockets. */
|
||||||
foreach(ShaderInput *in, sock->links) {
|
vector<ShaderInput*> links(output->links);
|
||||||
|
foreach(ShaderInput *in, links) {
|
||||||
in->value = optimized_value;
|
in->value = optimized_value;
|
||||||
disconnect(in);
|
disconnect(in);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user