diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-09-16 23:55:44 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-09-17 00:02:38 +0300 |
commit | 76650402f3004cc833be4b6c55059dd1ddd5a3bf (patch) | |
tree | c3e1cd1848d833e7f57603ca921202781539df8f /source/blender/blenkernel/intern/library.c | |
parent | 7a0ca9f98f0ec5c6c859606815019308d34624ef (diff) |
Fix T69931: Materials with keyframes duplicated by 'make single user' are linked.
Another sneaky bite from the infamous private ID data: While those
monsters are not in bmain, the actions used by their animdata are
regular cute little ID's, living with the herd in the safe and sound
Main DB...
So we have to be careful not to propagate the nasty black magic
required to handle the formers when we duplicate their animdata.
Saying it again: private ID datablocks should never have had their own
animdata & actions, this is endless issue also with RNA paths... And
makes copying of animation between materials and such needlessly
complicated.
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index bbee49e8150..6eb9de7aaf0 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1407,9 +1407,10 @@ void *BKE_id_new_nomain(const short type, const char *name) return id; } -void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, int flag) +void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int orig_flag) { ID *new_id = *r_newid; + int flag = orig_flag; const bool is_private_id_data = (id->flag & LIB_PRIVATE_DATA) != 0; @@ -1430,7 +1431,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, int flag) } /* The id->flag bits to copy over. */ - const int copy_flag_mask = LIB_PRIVATE_DATA; + const int copy_idflag_mask = LIB_PRIVATE_DATA; if ((flag & LIB_ID_CREATE_NO_ALLOCATE) != 0) { /* r_newid already contains pointer to allocated memory. */ @@ -1454,7 +1455,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, int flag) memcpy(cpn + id_offset, cp + id_offset, id_len - id_offset); } - new_id->flag = (new_id->flag & ~copy_flag_mask) | (id->flag & copy_flag_mask); + new_id->flag = (new_id->flag & ~copy_idflag_mask) | (id->flag & copy_idflag_mask); if (id->properties) { new_id->properties = IDP_CopyProperty_ex(id->properties, flag); @@ -1474,9 +1475,12 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, int flag) /* the duplicate should get a copy of the animdata */ if ((flag & LIB_ID_COPY_NO_ANIMDATA) == 0) { - BLI_assert((flag & LIB_ID_COPY_ACTIONS) == 0 || (flag & LIB_ID_CREATE_NO_MAIN) == 0 || - is_private_id_data); - iat->adt = BKE_animdata_copy(bmain, iat->adt, flag); + /* Note that even though horrors like root nodetrees are not in bmain, the actions they use + * in their anim data *are* in bmain... super-mega-hurra. */ + int animdata_flag = orig_flag; + BLI_assert((animdata_flag & LIB_ID_COPY_ACTIONS) == 0 || + (animdata_flag & LIB_ID_CREATE_NO_MAIN) == 0); + iat->adt = BKE_animdata_copy(bmain, iat->adt, animdata_flag); } else { iat->adt = NULL; |