Supplementary fix for #35640, internal node group trees (inside material, lamp, world, texture and scene) still keep their original library pointer when appending, making them uneditable. Clearing the
lib pointer now has been moved inside the id_clear_lib_data function, with an ugly switch statement to handle integrated node trees.
This commit is contained in:
@@ -172,9 +172,6 @@ void BKE_lamp_make_local(Lamp *la)
|
||||
if (la->id.lib == NULL) return;
|
||||
if (la->id.us == 1) {
|
||||
id_clear_lib_data(bmain, &la->id);
|
||||
/* nodetree uses same lib */
|
||||
if (la->nodetree)
|
||||
la->nodetree->id.lib = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -189,9 +186,6 @@ void BKE_lamp_make_local(Lamp *la)
|
||||
|
||||
if (is_local && is_lib == FALSE) {
|
||||
id_clear_lib_data(bmain, &la->id);
|
||||
/* nodetree uses same lib */
|
||||
if (la->nodetree)
|
||||
la->nodetree->id.lib = NULL;
|
||||
}
|
||||
else if (is_local && is_lib) {
|
||||
Lamp *la_new = BKE_lamp_copy(la);
|
||||
|
||||
@@ -1428,11 +1428,26 @@ bool new_id(ListBase *lb, ID *id, const char *tname)
|
||||
* don't have other library users. */
|
||||
void id_clear_lib_data(Main *bmain, ID *id)
|
||||
{
|
||||
bNodeTree *ntree = NULL;
|
||||
|
||||
BKE_id_lib_local_paths(bmain, id->lib, id);
|
||||
|
||||
id->lib = NULL;
|
||||
id->flag = LIB_LOCAL;
|
||||
new_id(which_libbase(bmain, GS(id->name)), id, NULL);
|
||||
|
||||
/* internal bNodeTree blocks inside ID types below
|
||||
* also stores id->lib, make sure this stays in sync.
|
||||
*/
|
||||
switch (GS(id->name)) {
|
||||
case ID_SCE: ntree = ((Scene *)id)->nodetree; break;
|
||||
case ID_MA: ntree = ((Material *)id)->nodetree; break;
|
||||
case ID_LA: ntree = ((Lamp *)id)->nodetree; break;
|
||||
case ID_WO: ntree = ((World *)id)->nodetree; break;
|
||||
case ID_TE: ntree = ((Tex *)id)->nodetree; break;
|
||||
}
|
||||
if (ntree)
|
||||
ntree->id.lib = NULL;
|
||||
}
|
||||
|
||||
/* next to indirect usage in read/writefile also in editobject.c scene.c */
|
||||
|
||||
@@ -308,9 +308,6 @@ void BKE_material_make_local(Material *ma)
|
||||
if (ma->id.us == 1) {
|
||||
id_clear_lib_data(bmain, &ma->id);
|
||||
extern_local_material(ma);
|
||||
/* nodetree uses same lib */
|
||||
if (ma->nodetree)
|
||||
ma->nodetree->id.lib = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -373,9 +370,6 @@ void BKE_material_make_local(Material *ma)
|
||||
if (is_local && is_lib == FALSE) {
|
||||
id_clear_lib_data(bmain, &ma->id);
|
||||
extern_local_material(ma);
|
||||
/* nodetree uses same lib */
|
||||
if (ma->nodetree)
|
||||
ma->nodetree->id.lib = NULL;
|
||||
}
|
||||
/* Both user and local, so copy. */
|
||||
else if (is_local && is_lib) {
|
||||
|
||||
@@ -765,9 +765,6 @@ void BKE_texture_make_local(Tex *tex)
|
||||
if (tex->id.us == 1) {
|
||||
id_clear_lib_data(bmain, &tex->id);
|
||||
extern_local_texture(tex);
|
||||
/* nodetree uses same lib */
|
||||
if (tex->nodetree)
|
||||
tex->nodetree->id.lib = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -827,9 +824,6 @@ void BKE_texture_make_local(Tex *tex)
|
||||
if (is_local && is_lib == FALSE) {
|
||||
id_clear_lib_data(bmain, &tex->id);
|
||||
extern_local_texture(tex);
|
||||
/* nodetree uses same lib */
|
||||
if (tex->nodetree)
|
||||
tex->nodetree->id.lib = NULL;
|
||||
}
|
||||
else if (is_local && is_lib) {
|
||||
Tex *tex_new = BKE_texture_copy(tex);
|
||||
|
||||
@@ -179,9 +179,6 @@ void BKE_world_make_local(World *wrld)
|
||||
if (wrld->id.lib == NULL) return;
|
||||
if (wrld->id.us == 1) {
|
||||
id_clear_lib_data(bmain, &wrld->id);
|
||||
/* nodetree uses same lib */
|
||||
if (wrld->nodetree)
|
||||
wrld->nodetree->id.lib = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -194,9 +191,6 @@ void BKE_world_make_local(World *wrld)
|
||||
|
||||
if (is_local && is_lib == FALSE) {
|
||||
id_clear_lib_data(bmain, &wrld->id);
|
||||
/* nodetree uses same lib */
|
||||
if (wrld->nodetree)
|
||||
wrld->nodetree->id.lib = NULL;
|
||||
}
|
||||
else if (is_local && is_lib) {
|
||||
World *wrld_new = BKE_world_copy(wrld);
|
||||
|
||||
Reference in New Issue
Block a user