Fix T47379: crash appending materials with node trees.
This commit is contained in:
parent
e8d7a0206e
commit
3c7369164e
Notes:
blender-bot
2023-02-14 08:13:41 +01:00
Referenced by issue #47379, crash when appending object with node group in material
|
@ -85,6 +85,7 @@ void id_sort_by_name(struct ListBase *lb, struct ID *id);
|
|||
|
||||
bool new_id(struct ListBase *lb, struct ID *id, const char *name);
|
||||
void id_clear_lib_data(struct Main *bmain, struct ID *id);
|
||||
void id_clear_lib_data_ex(struct Main *bmain, struct ID *id, bool id_in_mainlist);
|
||||
|
||||
struct ListBase *which_libbase(struct Main *mainlib, short type);
|
||||
|
||||
|
|
|
@ -347,7 +347,7 @@ void ntreeUserDecrefID(struct bNodeTree *ntree);
|
|||
|
||||
struct bNodeTree *ntreeFromID(struct ID *id);
|
||||
|
||||
void ntreeMakeLocal(struct bNodeTree *ntree);
|
||||
void ntreeMakeLocal(struct bNodeTree *ntree, bool id_in_mainlist);
|
||||
bool ntreeHasType(const struct bNodeTree *ntree, int type);
|
||||
bool ntreeHasTree(const struct bNodeTree *ntree, const struct bNodeTree *lookup);
|
||||
void ntreeUpdateTree(struct Main *main, struct bNodeTree *ntree);
|
||||
|
|
|
@ -323,7 +323,7 @@ bool id_make_local(ID *id, bool test)
|
|||
if (!test) BKE_action_make_local((bAction *)id);
|
||||
return true;
|
||||
case ID_NT:
|
||||
if (!test) ntreeMakeLocal((bNodeTree *)id);
|
||||
if (!test) ntreeMakeLocal((bNodeTree *)id, true);
|
||||
return true;
|
||||
case ID_BR:
|
||||
if (!test) BKE_brush_make_local((Brush *)id);
|
||||
|
@ -1654,7 +1654,7 @@ bool new_id(ListBase *lb, ID *id, const char *tname)
|
|||
* Pull an ID out of a library (make it local). Only call this for IDs that
|
||||
* don't have other library users.
|
||||
*/
|
||||
void id_clear_lib_data(Main *bmain, ID *id)
|
||||
void id_clear_lib_data_ex(Main *bmain, ID *id, bool id_in_mainlist)
|
||||
{
|
||||
bNodeTree *ntree = NULL;
|
||||
|
||||
|
@ -1664,7 +1664,8 @@ void id_clear_lib_data(Main *bmain, ID *id)
|
|||
|
||||
id->lib = NULL;
|
||||
id->tag &= ~(LIB_TAG_INDIRECT | LIB_TAG_EXTERN);
|
||||
new_id(which_libbase(bmain, GS(id->name)), id, NULL);
|
||||
if (id_in_mainlist)
|
||||
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.
|
||||
|
@ -1672,7 +1673,7 @@ void id_clear_lib_data(Main *bmain, ID *id)
|
|||
ntree = ntreeFromID(id);
|
||||
|
||||
if (ntree) {
|
||||
ntreeMakeLocal(ntree);
|
||||
ntreeMakeLocal(ntree, false);
|
||||
}
|
||||
|
||||
if (GS(id->name) == ID_OB) {
|
||||
|
@ -1685,6 +1686,11 @@ void id_clear_lib_data(Main *bmain, ID *id)
|
|||
}
|
||||
}
|
||||
|
||||
void id_clear_lib_data(Main *bmain, ID *id)
|
||||
{
|
||||
id_clear_lib_data_ex(bmain, id, true);
|
||||
}
|
||||
|
||||
/* next to indirect usage in read/writefile also in editobject.c scene.c */
|
||||
void BKE_main_id_clear_newpoins(Main *bmain)
|
||||
{
|
||||
|
|
|
@ -1979,7 +1979,7 @@ static void extern_local_ntree(bNodeTree *ntree)
|
|||
}
|
||||
}
|
||||
|
||||
void ntreeMakeLocal(bNodeTree *ntree)
|
||||
void ntreeMakeLocal(bNodeTree *ntree, bool id_in_mainlist)
|
||||
{
|
||||
Main *bmain = G.main;
|
||||
bool lib = false, local = false;
|
||||
|
@ -1991,7 +1991,7 @@ void ntreeMakeLocal(bNodeTree *ntree)
|
|||
|
||||
if (ntree->id.lib == NULL) return;
|
||||
if (ntree->id.us == 1) {
|
||||
id_clear_lib_data(bmain, (ID *)ntree);
|
||||
id_clear_lib_data_ex(bmain, (ID *)ntree, id_in_mainlist);
|
||||
extern_local_ntree(ntree);
|
||||
return;
|
||||
}
|
||||
|
@ -2012,7 +2012,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);
|
||||
id_clear_lib_data_ex(bmain, (ID *)ntree, id_in_mainlist);
|
||||
extern_local_ntree(ntree);
|
||||
}
|
||||
else if (local && lib) {
|
||||
|
|
Loading…
Reference in New Issue