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:
Sergey Sharybin 2015-11-25 20:01:08 +05:00
parent 485ea4353f
commit 1bec2aa54e

@ -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);
}