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:
Bastien Montagne
2016-01-09 09:22:42 +01:00
parent 425a4b23fd
commit 9691202585
2 changed files with 12 additions and 1 deletions

View File

@@ -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) {

View File

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