From a881b5272b01fe299df5d12aded30515c432bcec Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 18 May 2021 18:42:29 +0200 Subject: 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. --- source/blender/blenkernel/intern/lib_id.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3