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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user