Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2017-08-14 16:40:54 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2017-08-14 16:40:54 +0300
commit3cd51c0379638045cd32c9aa74215032d7bc381b (patch)
tree4097f5dfed8b06e8979c7ca1aadd380ed425d42e
parent03a02cd109c326e4998745520deca8db4837e27d (diff)
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...
-rw-r--r--source/blender/blenkernel/intern/library.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 08bbce84a77..d5dfc63b317 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -483,18 +483,20 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local)
struct IDCopyLibManagementData {
const ID *id_src;
+ ID *id_dst;
int flag;
};
/* 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;
ID *id = *id_pointer;
/* Remap self-references to new copied ID. */
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. */
@@ -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. */
- 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);
/* Do not make new copy local in case we are copying outside of main...