Fix user counting when ungrouping a node group.

Existing code for ungrouping did not correctly handle user counters:

- counter for the group was not decremented
- counters for containing nodes were not incremented

The latter resulted in losing some nodes after orphan cleaning or several save/reload cycles.

The bug did not have destructive consequences until recently,
because it was compensated by another bug (fixed in rBe993667a46c2).

Maniphest Tasks: T74665, T74682

Differential Revision: https://developer.blender.org/D7332
This commit is contained in:
Maxim Vasiliev 2020-04-06 16:23:43 +02:00 committed by Bastien Montagne
parent 95f51bb01d
commit c544df997e
Notes: blender-bot 2023-02-14 00:09:06 +01:00
Referenced by issue #74682, Ungroup Node Groups doesn't update its user count
Referenced by issue #74665, Ungrouping destroys NodeCustomGroups
1 changed files with 5 additions and 5 deletions

View File

@ -193,11 +193,11 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
}
/* wgroup is a temporary copy of the NodeTree we're merging in
* - all of wgroup's nodes are transferred across to their new home
* - all of wgroup's nodes are copied across to their new home
* - ngroup (i.e. the source NodeTree) is left unscathed
* - temp copy. don't change ID usercount
* - temp copy. do change ID usercount for the copies
*/
wgroup = ntreeCopyTree_ex_new_pointers(ngroup, bmain, false);
wgroup = ntreeCopyTree_ex_new_pointers(ngroup, bmain, true);
/* Add the nodes into the ntree */
for (node = wgroup->nodes.first; node; node = nextnode) {
@ -351,8 +351,8 @@ static int node_group_ungroup(Main *bmain, bNodeTree *ntree, bNode *gnode)
nodeRemoveNode(bmain, ntree, node, false);
}
/* delete the group instance */
nodeRemoveNode(bmain, ntree, gnode, false);
/* delete the group instance and dereference group tree */
nodeRemoveNode(bmain, ntree, gnode, true);
ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS;