From 03544ed54f8dc5fb28d2c6b655a4153286c0137f Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 14 Jun 2021 10:04:32 +0200 Subject: Fix T88807: crash when there are multiple links between the same sockets This commit does two things: * Disallows creating more than one link from one socket to a multi socket input. * Properly count links if there happen to be more than one link between the same sockets. The new link counting should also be more efficient asymptotically. Differential Revision: https://developer.blender.org/D11570 --- source/blender/makesrna/intern/rna_nodetree.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/blender/makesrna/intern/rna_nodetree.c') diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index b625f0fc204..2a1ea3d6716 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -1283,6 +1283,13 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, if (nodeCountSocketLinks(ntree, tosock) + 1 > nodeSocketLinkLimit(tosock)) { nodeRemSocketLinks(ntree, tosock); } + if (tosock->flag & SOCK_MULTI_INPUT) { + LISTBASE_FOREACH_MUTABLE (bNodeLink *, link, &ntree->links) { + if (link->fromsock == fromsock && link->tosock == tosock) { + nodeRemLink(ntree, link); + } + } + } } ret = nodeAddLink(ntree, fromnode, fromsock, tonode, tosock); -- cgit v1.2.3