[Bf-blender-cvs] [a881b5272b0] master: Fix ID copying outside of Main affecting 'directly linked' status of other IDs.

Bastien Montagne noreply at git.blender.org
Tue May 18 18:47:35 CEST 2021


Commit: a881b5272b01fe299df5d12aded30515c432bcec
Author: Bastien Montagne
Date:   Tue May 18 18:42:29 2021 +0200
Branches: master
https://developer.blender.org/rBa881b5272b01fe299df5d12aded30515c432bcec

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.

===================================================================

M	source/blender/blenkernel/intern/lib_id.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list