[Bf-blender-cvs] [c395d04] master: Fix T49082: Intermediate update call when making links can change group socket layout.

Lukas Tönne noreply at git.blender.org
Sat Aug 13 16:35:46 CEST 2016


Commit: c395d044fcce02321f1689b8b025369fb2dbd6a6
Author: Lukas Tönne
Date:   Sat Aug 13 16:31:46 2016 +0200
Branches: master
https://developer.blender.org/rBc395d044fcce02321f1689b8b025369fb2dbd6a6

Fix T49082: Intermediate update call when making links can change group socket layout.

Node tree update calls in the middle of a socket loop are dangerous, they can change sockets
on group nodes and link instances in particular. Updates should only happen after the operator
has finished.

Simply removed the extra convenience check for validity now. Worst case an invalid (red) link
is created which can be removed by the user as well and should simply be ignored by node systems.

The update system in nodes needs a complete rewrite to handle complex cases like this, where an
operator may need to react to changes during its execution.

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

M	source/blender/editors/space_node/node_relationships.c

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

diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c
index ea3869e..5f59243 100644
--- a/source/blender/editors/space_node/node_relationships.c
+++ b/source/blender/editors/space_node/node_relationships.c
@@ -276,25 +276,16 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in
 	return NULL;
 }
 
-static int snode_autoconnect_input(SpaceNode *snode, bNode *node_fr, bNodeSocket *sock_fr, bNode *node_to, bNodeSocket *sock_to, int replace)
+static bool snode_autoconnect_input(SpaceNode *snode, bNode *node_fr, bNodeSocket *sock_fr, bNode *node_to, bNodeSocket *sock_to, int replace)
 {
 	bNodeTree *ntree = snode->edittree;
-	bNodeLink *link;
 
 	/* then we can connect */
 	if (replace)
 		nodeRemSocketLinks(ntree, sock_to);
 
-	link = nodeAddLink(ntree, node_fr, sock_fr, node_to, sock_to);
-	/* validate the new link */
-	ntreeUpdateTree(G.main, ntree);
-	if (!(link->flag & NODE_LINK_VALID)) {
-		nodeRemLink(ntree, link);
-		return 0;
-	}
-
-	snode_update(snode, node_to);
-	return 1;
+	nodeAddLink(ntree, node_fr, sock_fr, node_to, sock_to);
+	return true;
 }
 
 static void snode_autoconnect(SpaceNode *snode, const bool allow_multiple, const bool replace)




More information about the Bf-blender-cvs mailing list