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:
parent
fcb78f2402
commit
c395d044fc
Notes:
blender-bot
2023-02-14 07:42:01 +01:00
Referenced by issue #49082, Crash when connecting nodes with to node group input or output
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue