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 :)
This commit is contained in:
Antonis Ryakiotakis 2014-11-06 17:55:55 +01:00
parent a91888206f
commit 4542504162
Notes: blender-bot 2023-02-14 09:50:46 +01:00
Referenced by issue #42541, Boolean Problem
Referenced by issue #42530, SubD doesn't do anything on a mesh
Referenced by issue #42525, Crash after removing lamp, linked to "Lamp Data" shader node in Material Mode.
1 changed files with 10 additions and 14 deletions

View File

@ -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 */