Fix T47121: Image node on linked and localized material loses image after reopening project.
Code 'localizing' the node of an ID (a material, here) was kind of a joke, setting id.lib to NULL is not enough, by far! Now calling ntreeMakeLocal(). And ntreeMakeLocal was also missing indirect->extern switch for its directly used IDs, which explains why they were lost after a save/reload. Note that here again, a big part of this 'localizing' code should be made generic using library_query stuff, but this is for id-remap, not current master...
This commit is contained in:
parent
425a4b23fd
commit
9691202585
Notes:
blender-bot
2023-02-14 08:19:29 +01:00
Referenced by issue #48844, Appended Cycles materials are not editable in Properties panel/Node Editor Referenced by issue #47121, Image node on linked and localized material loses image after reopening project.
|
@ -1672,7 +1672,7 @@ void id_clear_lib_data(Main *bmain, ID *id)
|
|||
ntree = ntreeFromID(id);
|
||||
|
||||
if (ntree) {
|
||||
ntree->id.lib = NULL;
|
||||
ntreeMakeLocal(ntree);
|
||||
}
|
||||
|
||||
if (GS(id->name) == ID_OB) {
|
||||
|
|
|
@ -1970,6 +1970,15 @@ bNodeTree *ntreeFromID(ID *id)
|
|||
}
|
||||
}
|
||||
|
||||
static void extern_local_ntree(bNodeTree *ntree)
|
||||
{
|
||||
for (bNode *node = ntree->nodes.first; node; node = node->next) {
|
||||
if (node->id) {
|
||||
id_lib_extern(node->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ntreeMakeLocal(bNodeTree *ntree)
|
||||
{
|
||||
Main *bmain = G.main;
|
||||
|
@ -1983,6 +1992,7 @@ void ntreeMakeLocal(bNodeTree *ntree)
|
|||
if (ntree->id.lib == NULL) return;
|
||||
if (ntree->id.us == 1) {
|
||||
id_clear_lib_data(bmain, (ID *)ntree);
|
||||
extern_local_ntree(ntree);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2003,6 +2013,7 @@ void ntreeMakeLocal(bNodeTree *ntree)
|
|||
/* if all users are local, we simply make tree local */
|
||||
if (local && !lib) {
|
||||
id_clear_lib_data(bmain, (ID *)ntree);
|
||||
extern_local_ntree(ntree);
|
||||
}
|
||||
else if (local && lib) {
|
||||
/* this is the mixed case, we copy the tree and assign it to local users */
|
||||
|
|
Loading…
Reference in New Issue