From 4542504162a2962188e708e8b7dab609bddc0865 Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Thu, 6 Nov 2014 17:55:55 +0100 Subject: 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 :) --- source/blender/blenkernel/intern/object.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b910e11beed..96c5944794e 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 */ -- cgit v1.2.3