Commit: 4542504162a2962188e708e8b7dab609bddc0865
Author: Antony Riakiotakis
Date:   Thu Nov 6 17:55:55 2014 +0100
Branches: master
https://developer.blender.org/rB4542504162a2962188e708e8b7dab609bddc0865

better fix for fix T42525 (tm)

Looks like material node trees are stored directly in the material. The
reason I thought this was fixed was because my test file didn't connect
the lamp data node in the rest of the tree.

Thanks to Campbell for catching this :)

===================================================================

M       source/blender/blenkernel/intern/object.c

===================================================================

diff --git a/source/blender/blenkernel/intern/object.c 
b/source/blender/blenkernel/intern/object.c
index b910e11..96c5944 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -96,6 +96,7 @@
 #include "BKE_editmesh.h"
 #include "BKE_mball.h"
 #include "BKE_modifier.h"
+#include "BKE_node.h"
 #include "BKE_object.h"
 #include "BKE_paint.h"
 #include "BKE_particle.h"
@@ -436,7 +437,6 @@ void BKE_object_unlink(Object *ob)
        SceneRenderLayer *srl;
        FreestyleLineSet *lineset;
        bNodeTree *ntree;
-       bNode *node;
        Curve *cu;
        Tex *tex;
        Group *group;
@@ -638,17 +638,22 @@ void BKE_object_unlink(Object *ob)
        }
        
        /* materials */
-       mat = bmain->mat.first;
-       while (mat) {
-       
+       for (mat = bmain->mat.first; mat; mat = mat->id.next) {
+               if (mat->nodetree) {
+                       ntreeSwitchID(mat->nodetree, &ob->id, NULL);
+               }
                for (a = 0; a < MAX_MTEX; a++) {
                        if (mat->mtex[a] && ob == mat->mtex[a]->object) {
                                /* actually, test for lib here... to do */
                                mat->mtex[a]->object = NULL;
                        }
                }
+       }
 
-               mat = mat->id.next;
+       /* node trees */
+       for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) {
+               if (ntree->type == NTREE_SHADER)
+                       ntreeSwitchID(ntree, &ob->id, NULL);
        }
        
        /* textures */
@@ -813,15 +818,6 @@ void BKE_object_unlink(Object *ob)
                }
                camera = camera->id.next;
        }
-
-       /* nodes */
-       for (ntree = bmain->nodetree.first; ntree; ntree = ntree->id.next) {
-               for (node = ntree->nodes.first; node; node = node->next) {
-                       if (node->id == &ob->id) {
-                               node->id = NULL;
-                       }
-               }
-       }
 }
 
 /* actual check for internal data, not context or flags */

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to