Fix T52092: Crash un-grouping nodes

This commit is contained in:
Campbell Barton 2017-07-19 14:32:31 +10:00
parent 8b2785bda5
commit 3daa641d7f
Notes: blender-bot 2023-02-14 11:00:17 +01:00
Referenced by issue #52092, Crash when unlinking group with directly connected sockets
1 changed files with 9 additions and 2 deletions

View File

@ -37,6 +37,7 @@
#include "DNA_anim_types.h"
#include "BLI_listbase.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLT_translation.h"
@ -186,6 +187,7 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
bNode *node, *nextnode;
bNodeTree *ngroup, *wgroup;
ListBase anim_basepaths = {NULL, NULL};
LinkNode *nodes_delayed_free = NULL;
ngroup = (bNodeTree *)gnode->id;
@ -208,8 +210,8 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
* This also removes remaining links to and from interface nodes.
*/
if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) {
nodeFreeNode(wgroup, node);
continue;
/* We must delay removal since sockets will reference this node. see: T52092 */
BLI_linklist_prepend(&nodes_delayed_free, node);
}
/* keep track of this node's RNA "base" path (the part of the path identifying the node)
@ -336,6 +338,11 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
}
}
while (nodes_delayed_free) {
node = BLI_linklist_pop(&nodes_delayed_free);
nodeFreeNode(ntree, node);
}
/* delete the group instance */
nodeFreeNode(ntree, gnode);