all areas of blender now do node tree id user count management, except for some excep...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 22 Aug 2012 09:35:46 +0000 (09:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 22 Aug 2012 09:35:46 +0000 (09:35 +0000)
source/blender/blenkernel/intern/lamp.c
source/blender/blenkernel/intern/library.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/node.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/world.c
source/blender/editors/space_node/node_group.c

index 6a80223..4782d09 100644 (file)
@@ -120,7 +120,7 @@ Lamp *BKE_lamp_copy(Lamp *la)
        lan->curfalloff = curvemapping_copy(la->curfalloff);
 
        if (la->nodetree)
-               lan->nodetree = ntreeCopyTree_ex(la->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               lan->nodetree = ntreeCopyTree(la->nodetree);
        
        if (la->preview)
                lan->preview = BKE_previewimg_copy(la->preview);
@@ -223,7 +223,7 @@ void BKE_lamp_free(Lamp *la)
 
        /* is no lib link block, but lamp extension */
        if (la->nodetree) {
-               ntreeFreeTree_ex(la->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               ntreeFreeTree(la->nodetree);
                MEM_freeN(la->nodetree);
        }
        
index f1d1d12..e073cfd 100644 (file)
@@ -348,7 +348,7 @@ int id_copy(ID *id, ID **newid, int test)
                        if (!test) *newid = (ID *)BKE_action_copy((bAction *)id);
                        return 1;
                case ID_NT:
-                       if (!test) *newid = (ID *)ntreeCopyTree_ex((bNodeTree *)id, FALSE); /* TODO: do_id_user arg needs checking */
+                       if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id);
                        return 1;
                case ID_BR:
                        if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id);
@@ -881,7 +881,7 @@ void BKE_libblock_free(ListBase *lb, void *idv)
                        BKE_action_free((bAction *)id);
                        break;
                case ID_NT:
-                       ntreeFreeTree_ex((bNodeTree *)id, FALSE); /* TODO: do_id_user arg needs checking */
+                       ntreeFreeTree((bNodeTree *)id);
                        break;
                case ID_BR:
                        BKE_brush_free((Brush *)id);
index a1288b8..8a26a1b 100644 (file)
@@ -101,7 +101,7 @@ void BKE_material_free(Material *ma)
        
        /* is no lib link block, but material extension */
        if (ma->nodetree) {
-               ntreeFreeTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               ntreeFreeTree(ma->nodetree);
                MEM_freeN(ma->nodetree);
        }
 
@@ -235,7 +235,7 @@ Material *BKE_material_copy(Material *ma)
        if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview);
 
        if (ma->nodetree) {
-               man->nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               man->nodetree = ntreeCopyTree(ma->nodetree);
        }
 
        man->gpumaterial.first = man->gpumaterial.last = NULL;
@@ -1483,7 +1483,11 @@ void ramp_blend(int type, float r_col[3], const float fac, const float col[3])
        }
 }
 
-/* copy/paste buffer, if we had a propper py api that would be better */
+/**
+ * \brief copy/paste buffer, if we had a propper py api that would be better
+ * \note matcopybuf.nodetree does _NOT_ use ID's
+ * \todo matcopybuf.nodetree's  node->id's are NOT validated, this will crash!
+ */
 static Material matcopybuf;
 static short matcopied = 0;
 
@@ -1511,7 +1515,7 @@ void free_matcopybuf(void)
        matcopybuf.ramp_spec = NULL;
 
        if (matcopybuf.nodetree) {
-               ntreeFreeTree_ex(matcopybuf.nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               ntreeFreeTree_ex(matcopybuf.nodetree, FALSE);
                MEM_freeN(matcopybuf.nodetree);
                matcopybuf.nodetree = NULL;
        }
@@ -1537,7 +1541,7 @@ void copy_matcopybuf(Material *ma)
                        matcopybuf.mtex[a] = MEM_dupallocN(mtex);
                }
        }
-       matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+       matcopybuf.nodetree = ntreeCopyTree_ex(ma->nodetree, FALSE);
        matcopybuf.preview = NULL;
        matcopybuf.gpumaterial.first = matcopybuf.gpumaterial.last = NULL;
        matcopied = 1;
@@ -1561,7 +1565,7 @@ void paste_matcopybuf(Material *ma)
        }
 
        if (ma->nodetree) {
-               ntreeFreeTree_ex(ma->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               ntreeFreeTree(ma->nodetree);
                MEM_freeN(ma->nodetree);
        }
 
@@ -1582,7 +1586,7 @@ void paste_matcopybuf(Material *ma)
                }
        }
 
-       ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+       ma->nodetree = ntreeCopyTree_ex(matcopybuf.nodetree, FALSE);
 }
 
 
index b67288f..3756268 100644 (file)
@@ -1188,7 +1188,7 @@ void ntreeMakeLocal(bNodeTree *ntree)
        }
        else if (cd.local && cd.lib) {
                /* this is the mixed case, we copy the tree and assign it to local users */
-               bNodeTree *newtree = ntreeCopyTree_ex(ntree, FALSE); /* TODO: do_id_user arg needs checking */
+               bNodeTree *newtree = ntreeCopyTree(ntree);
                
                newtree->id.us = 0;
                
@@ -1299,7 +1299,7 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree)
        if (ntreetype->local_merge)
                ntreetype->local_merge(localtree, ntree);
 
-       ntreeFreeTree_ex(localtree, FALSE); /* TODO: do_id_user arg needs checking */
+       ntreeFreeTree_ex(localtree, FALSE);
        MEM_freeN(localtree);
 }
 
index 66b096b..2f54fe6 100644 (file)
@@ -430,7 +430,7 @@ void BKE_texture_free(Tex *tex)
        tex->id.icon_id = 0;
        
        if (tex->nodetree) {
-               ntreeFreeTree_ex(tex->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               ntreeFreeTree(tex->nodetree);
                MEM_freeN(tex->nodetree);
        }
 }
@@ -697,7 +697,7 @@ Tex *BKE_texture_copy(Tex *tex)
                if (tex->nodetree->execdata) {
                        ntreeTexEndExecTree(tex->nodetree->execdata, 1);
                }
-               texn->nodetree = ntreeCopyTree_ex(tex->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               texn->nodetree = ntreeCopyTree(tex->nodetree);
        }
        
        return texn;
index 418d7da..dd71e43 100644 (file)
@@ -67,7 +67,7 @@ void BKE_world_free(World *wrld)
 
        /* is no lib link block, but world extension */
        if (wrld->nodetree) {
-               ntreeFreeTree_ex(wrld->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               ntreeFreeTree(wrld->nodetree);
                MEM_freeN(wrld->nodetree);
        }
 
@@ -129,7 +129,7 @@ World *BKE_world_copy(World *wrld)
        }
 
        if (wrld->nodetree) {
-               wrldn->nodetree = ntreeCopyTree_ex(wrld->nodetree, FALSE); /* TODO: do_id_user arg needs checking */
+               wrldn->nodetree = ntreeCopyTree(wrld->nodetree);
        }
        
        if (wrld->preview)
index 4e35297..77583ae 100644 (file)
@@ -421,10 +421,11 @@ static int node_group_ungroup(bNodeTree *ntree, bNode *gnode)
                node->new_node = NULL;
 
        /* wgroup is a temporary copy of the NodeTree we're merging in
-        *      - all of wgroup's nodes are transferred across to their new home
-        *      - ngroup (i.e. the source NodeTree) is left unscathed
+        * - all of wgroup's nodes are transferred across to their new home
+        * - ngroup (i.e. the source NodeTree) is left unscathed
+        * - temp copy. don't change ID usercount
         */
-       wgroup = ntreeCopyTree_ex(ngroup, FALSE); /* TODO: do_id_user arg needs checking */
+       wgroup = ntreeCopyTree_ex(ngroup, FALSE);
 
        /* add the nodes into the ntree */
        for (node = wgroup->nodes.first; node; node = nextn) {