Fix T89709: avoid double node links after delete and reconnect

Differential Revision: https://developer.blender.org/D13062
This commit is contained in:
Colin 2021-11-03 17:53:41 +01:00 committed by Jacques Lucke
parent 1e590234f7
commit a827864e6b
Notes: blender-bot 2023-02-17 21:23:49 +01:00
Referenced by issue #89709, Delete with reconnect can cause two links from same socket to go to the same multi_input socket
Referenced by issue #104604, Nodes: Removing and freeing the next one during a linkbase iterating
Referenced by issue #104604, Nodes: Removing and freeing the next one during a linkbase iterating
1 changed files with 11 additions and 0 deletions

View File

@ -2601,6 +2601,17 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node)
bNodeLink *fromlink = link->fromsock->link->fromsock->link;
/* skip the node */
if (fromlink) {
if (link->tosock->flag & SOCK_MULTI_INPUT) {
/* remove the link that would be the same as the relinked one */
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link_to_compare, &ntree->links) {
if (link_to_compare->fromsock == fromlink->fromsock &&
link_to_compare->tosock == link->tosock) {
adjust_multi_input_indices_after_removed_link(
ntree, link_to_compare->tosock, link_to_compare->multi_input_socket_index);
nodeRemLink(ntree, link_to_compare);
}
}
}
link->fromnode = fromlink->fromnode;
link->fromsock = fromlink->fromsock;