diff options
author | Bastien Montagne <bastien@blender.org> | 2021-05-18 19:42:29 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-05-18 19:44:39 +0300 |
commit | a881b5272b01fe299df5d12aded30515c432bcec (patch) | |
tree | c15c2f9847aeda8bbabfa93117860209a95f6ac1 /source/blender/blenkernel/intern/lib_id.c | |
parent | 3826c161ad30b12fcba4799e1047eed1de3e229f (diff) |
Fix ID copying outside of Main affecting 'directly linked' status of other IDs.
Copying an ID outside of BMain should not assume that the datablocks it
uses are now directly linked. This would be wrong e.g. in case that new
no-main ID is copied from a linked data-block and is supposed to remain
a linked data.
Diffstat (limited to 'source/blender/blenkernel/intern/lib_id.c')
-rw-r--r-- | source/blender/blenkernel/intern/lib_id.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 37fb44ec231..df7a4a862ea 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -525,7 +525,13 @@ static int id_copy_libmanagement_cb(LibraryIDLinkCallbackData *cb_data) /* Increase used IDs refcount if needed and required. */ if ((data->flag & LIB_ID_CREATE_NO_USER_REFCOUNT) == 0 && (cb_flag & IDWALK_CB_USER)) { - id_us_plus(id); + if ((data->flag & LIB_ID_CREATE_NO_MAIN) != 0) { + BLI_assert(cb_data->id_self->tag & LIB_TAG_NO_MAIN); + id_us_plus_no_lib(id); + } + else { + id_us_plus(id); + } } return IDWALK_RET_NOP; |