[Bf-blender-cvs] [1bec2aa] master: Cycles: Fix crash in constant folding introduced by recent commit

Sergey Sharybin noreply at git.blender.org
Wed Nov 25 16:14:39 CET 2015


Commit: 1bec2aa54e85f4b7aceab98aee705516e4a96e1c
Author: Sergey Sharybin
Date:   Wed Nov 25 20:01:08 2015 +0500
Branches: master
https://developer.blender.org/rB1bec2aa54e85f4b7aceab98aee705516e4a96e1c

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!

===================================================================

M	intern/cycles/render/graph.cpp

===================================================================

diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 8468690..2977555 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);
 			}




More information about the Bf-blender-cvs mailing list