[Bf-blender-cvs] [d779b154853] master: Fix (unreported) bad handling of ID usercount increment in remapping code.

Bastien Montagne noreply at git.blender.org
Fri Apr 29 17:57:52 CEST 2022


Commit: d779b154853afba9cb2a30826c2c7f30237153e3
Author: Bastien Montagne
Date:   Fri Apr 29 16:33:48 2022 +0200
Branches: master
https://developer.blender.org/rBd779b154853afba9cb2a30826c2c7f30237153e3

Fix (unreported) bad handling of ID usercount increment in remapping code.

While this only had minor potential effect, both code incrementing
usercount of newly remapped IDs were wrong.

Original one would by-pass any 'ensured user' handling, newer one would
systematically make the ID directly linked...

`id_us_plus_no_lib` is to be used here.

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

M	source/blender/blenkernel/intern/lib_id_remapper.cc
M	source/blender/blenkernel/intern/lib_remap.c

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

diff --git a/source/blender/blenkernel/intern/lib_id_remapper.cc b/source/blender/blenkernel/intern/lib_id_remapper.cc
index 7696386c87d..7e75e0f5d93 100644
--- a/source/blender/blenkernel/intern/lib_id_remapper.cc
+++ b/source/blender/blenkernel/intern/lib_id_remapper.cc
@@ -86,7 +86,8 @@ struct IDRemapper {
     }
 
     if (options & ID_REMAP_APPLY_UPDATE_REFCOUNT) {
-      id_us_plus(*r_id_ptr);
+      /* Do not handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */
+      id_us_plus_no_lib(*r_id_ptr);
     }
 
     if (options & ID_REMAP_APPLY_ENSURE_REAL) {
diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c
index 2b449ad50bb..3f40c9d2088 100644
--- a/source/blender/blenkernel/intern/lib_remap.c
+++ b/source/blender/blenkernel/intern/lib_remap.c
@@ -131,8 +131,8 @@ static void foreach_libblock_remap_callback_apply(ID *id_owner,
       id_us_min(old_id);
     }
     if (new_id != NULL && (force_user_refcount || (new_id->tag & LIB_TAG_NO_MAIN) == 0)) {
-      /* We do not want to handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */
-      new_id->us++;
+      /* Do not handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */
+      id_us_plus_no_lib(new_id);
     }
   }
   else if (cb_flag & IDWALK_CB_USER_ONE) {



More information about the Bf-blender-cvs mailing list