Fix: memory leak with muted group nodes in localized shader node trees
The leak happens when there is a muted group node in a shader node tree which is rendered. For rendering, the drawing code "localizes" the node tree which also means duplicating the node groups used by each group node (might even duplicate the same group more than once if it's used by multiple nodes). Generally, this works fine, because all of these duplicates are freed when the tree is flattened. However, there is a preprocessing step which deletes all muted nodes from the tree. This code path did not free the groups recursively. Pull Request: https://projects.blender.org/blender/blender/pulls/129124
This commit is contained in:
@@ -129,6 +129,14 @@ static void localize(bNodeTree *localtree, bNodeTree * /*ntree*/)
|
||||
/* replace muted nodes and reroute nodes by internal links */
|
||||
LISTBASE_FOREACH_MUTABLE (bNode *, node, &localtree->nodes) {
|
||||
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
|
||||
if (node->is_group() && node->id) {
|
||||
/* Free the group like in #ntree_shader_groups_flatten. */
|
||||
bNodeTree *group = reinterpret_cast<bNodeTree *>(node->id);
|
||||
blender::bke::node_tree_free_tree(group);
|
||||
MEM_freeN(group);
|
||||
node->id = nullptr;
|
||||
}
|
||||
|
||||
blender::bke::node_internal_relink(localtree, node);
|
||||
blender::bke::node_tree_free_local_node(localtree, node);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user