forked from bartvdbraak/blender
Fix T52391: Crash on duplicating material.
Bug in new ID copying code, thanks once again to stupid nodetrees, we ended up wrongly remapping MA node->id pointers to NodeTree when copying materials using node trees...
This commit is contained in:
parent
03a02cd109
commit
3cd51c0379
@ -483,18 +483,20 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
|
|||||||
|
|
||||||
struct IDCopyLibManagementData {
|
struct IDCopyLibManagementData {
|
||||||
const ID *id_src;
|
const ID *id_src;
|
||||||
|
ID *id_dst;
|
||||||
int flag;
|
int flag;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Increases usercount as required, and remap self ID pointers. */
|
/* Increases usercount as required, and remap self ID pointers. */
|
||||||
static int id_copy_libmanagement_cb(void *user_data, ID *id_self, ID **id_pointer, int cb_flag)
|
static int id_copy_libmanagement_cb(void *user_data, ID *UNUSED(id_self), ID **id_pointer, int cb_flag)
|
||||||
{
|
{
|
||||||
struct IDCopyLibManagementData *data = user_data;
|
struct IDCopyLibManagementData *data = user_data;
|
||||||
ID *id = *id_pointer;
|
ID *id = *id_pointer;
|
||||||
|
|
||||||
/* Remap self-references to new copied ID. */
|
/* Remap self-references to new copied ID. */
|
||||||
if (id == data->id_src) {
|
if (id == data->id_src) {
|
||||||
id = *id_pointer = id_self;
|
/* We cannot use id_self here, it is not *always* id_dst (thanks to $£!+@#&/? nodetrees). */
|
||||||
|
id = *id_pointer = data->id_dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increase used IDs refcount if needed and required. */
|
/* Increase used IDs refcount if needed and required. */
|
||||||
@ -643,7 +645,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag, con
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update ID refcount, remap pointers to self in new ID. */
|
/* Update ID refcount, remap pointers to self in new ID. */
|
||||||
struct IDCopyLibManagementData data = {.id_src = id, .flag = flag};
|
struct IDCopyLibManagementData data = {.id_src = id, .id_dst = *r_newid, .flag = flag};
|
||||||
BKE_library_foreach_ID_link(bmain, *r_newid, id_copy_libmanagement_cb, &data, IDWALK_NOP);
|
BKE_library_foreach_ID_link(bmain, *r_newid, id_copy_libmanagement_cb, &data, IDWALK_NOP);
|
||||||
|
|
||||||
/* Do not make new copy local in case we are copying outside of main...
|
/* Do not make new copy local in case we are copying outside of main...
|
||||||
|
Loading…
Reference in New Issue
Block a user