Revision: 60475 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60475 Author: lukastoenne Date: 2013-10-01 09:29:56 +0000 (Tue, 01 Oct 2013) Log Message: ----------- Yet another fix for node groups localization: The ntreeLocalMerge function can not be used to free localized node groups, because it is not commonly called to free the localized node trees. Instead these data blocks are freed using the standard ntreeFreeTree function, so freeing localized node groups has to be done there. This means an ugly loop over G.main to detect localized groups, but should not be a big problem in practice.
Modified Paths: -------------- trunk/blender/source/blender/blenkernel/intern/node.c Modified: trunk/blender/source/blender/blenkernel/intern/node.c =================================================================== --- trunk/blender/source/blender/blenkernel/intern/node.c 2013-10-01 09:17:35 UTC (rev 60474) +++ trunk/blender/source/blender/blenkernel/intern/node.c 2013-10-01 09:29:56 UTC (rev 60475) @@ -1663,6 +1663,28 @@ MEM_freeN(sock->default_value); } +static void free_localized_node_groups(bNodeTree *ntree) +{ + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == NODE_GROUP && node->id) { + bNodeTree *ngroup = (bNodeTree *)node->id, *tntree; + + /* is ntree part of library? */ + for (tntree = G.main->nodetree.first; tntree; tntree = tntree->id.next) + if (tntree == ngroup) + break; + + if (tntree == NULL) { + /* ntree is not in library, i.e. localized node group: free it */ + ntreeFreeTree_ex(ngroup, false); + MEM_freeN(ngroup); + } + } + } +} + /* do not free ntree itself here, BKE_libblock_free calls this function too */ void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user) { @@ -1689,6 +1711,9 @@ } } + /* XXX not nice, but needed to free localized node groups properly */ + free_localized_node_groups(ntree); + /* unregister associated RNA types */ ntreeInterfaceTypeFree(ntree); @@ -1990,24 +2015,10 @@ /* we have to assume the editor already changed completely */ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree) { - bNode *node; - - if (localtree) { - if (ntree) { - if (ntree->typeinfo->local_merge) - ntree->typeinfo->local_merge(localtree, ntree); - } + if (ntree && localtree) { + if (ntree->typeinfo->local_merge) + ntree->typeinfo->local_merge(localtree, ntree); - for (node = localtree->nodes.first; node; node = node->next) { - if (node->type == NODE_GROUP && node->id) { - bNodeTree *localgroup = (bNodeTree *)node->id; - /* not passing original node tree for node group merge, - * because there may be multiple instances using the same group tree. - */ - ntreeLocalMerge(localgroup, NULL); - } - } - ntreeFreeTree_ex(localtree, FALSE); MEM_freeN(localtree); } _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs