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>2019-09-12 13:24:24 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-09-12 13:27:39 +0300
commit013750947657fcdea313782d82ec51cc111f0c06 (patch)
tree73814d146a2b8e06db31051bcaf11cba916de726 /source/blender/blenkernel/intern/library.c
parent4df75063e1ca4396b8eb6d72f39e3cded831b72f (diff)
Fix T69789: Assert when create a new Full Copy scene base on 2D template.
Private ID data (nodetrees and scene collections...) need special care and handling of their copy flags, and checks must be adapted too. In that case, issue came from the fact that even though those IDs have to be copied outside of bmain, we may still require usercount handling. That commit also fixes a somewhat related issue - we cannot use the non-id private data copying flag for private IDs copying, due to difference in handling of usercount again.
Diffstat (limited to 'source/blender/blenkernel/intern/library.c')
-rw-r--r--source/blender/blenkernel/intern/library.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index f37d1dd5eed..bbee49e8150 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -1411,14 +1411,21 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, int flag)
{
ID *new_id = *r_newid;
+ const bool is_private_id_data = (id->flag & LIB_PRIVATE_DATA) != 0;
+
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) != 0 || bmain != NULL);
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) != 0 || (flag & LIB_ID_CREATE_NO_ALLOCATE) == 0);
- BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) == 0 || (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0);
+ if (!is_private_id_data) {
+ /* When we are handling private ID data, we might still want to manage usercounts, even though
+ * that ID data-block is actually outside of Main... */
+ BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) == 0 ||
+ (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0);
+ }
/* Never implicitly copy shapekeys when generating temp data outside of Main database. */
BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) == 0 || (flag & LIB_ID_COPY_SHAPEKEY) == 0);
/* 'Private ID' data handling. */
- if ((bmain != NULL) && (id->flag & LIB_PRIVATE_DATA) != 0) {
+ if ((bmain != NULL) && is_private_id_data) {
flag |= LIB_ID_CREATE_NO_MAIN;
}
@@ -1467,7 +1474,8 @@ 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);
+ 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);
}
else {