[Bf-blender-cvs] [0fb55ff845f] blender-v2.81-release: Fix T70787: Duplicating objects with custom property of type ID creates bogus links.
Bastien Montagne
noreply at git.blender.org
Mon Oct 14 11:16:59 CEST 2019
Commit: 0fb55ff845fcaa76d9b540c2fbdd3e1b4671a7e7
Author: Bastien Montagne
Date: Mon Oct 14 11:12:13 2019 +0200
Branches: blender-v2.81-release
https://developer.blender.org/rB0fb55ff845fcaa76d9b540c2fbdd3e1b4671a7e7
Fix T70787: Duplicating objects with custom property of type ID creates bogus links.
Note that the issue also affected animdata handling...
Checked all usages of the `BKE_libblock_copy_ex()` function, and
think never handling user count here is valid, although a bit risky
maybe. But other solution would be to add yet another copy flag, so
would rather go with that one for now.
===================================================================
M source/blender/blenkernel/intern/library.c
===================================================================
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 468d0e97ece..909db9c7b52 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1468,8 +1468,12 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
new_id->flag = (new_id->flag & ~copy_idflag_mask) | (id->flag & copy_idflag_mask);
+ /* We do not want any handling of usercount in code duplicating the data here, we do that all
+ * at once in id_copy_libmanagement_cb() at the end. */
+ const int copy_data_flag = orig_flag | LIB_ID_CREATE_NO_USER_REFCOUNT;
+
if (id->properties) {
- new_id->properties = IDP_CopyProperty_ex(id->properties, flag);
+ new_id->properties = IDP_CopyProperty_ex(id->properties, copy_data_flag);
}
/* XXX Again... We need a way to control what we copy in a much more refined way.
@@ -1488,10 +1492,9 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori
if ((flag & LIB_ID_COPY_NO_ANIMDATA) == 0) {
/* 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-hooray. */
- 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);
+ BLI_assert((copy_data_flag & LIB_ID_COPY_ACTIONS) == 0 ||
+ (copy_data_flag & LIB_ID_CREATE_NO_MAIN) == 0);
+ iat->adt = BKE_animdata_copy(bmain, iat->adt, copy_data_flag);
}
else {
iat->adt = NULL;
More information about the Bf-blender-cvs
mailing list