[Bf-blender-cvs] [20f87854638] temp-T94185-id-remapper-ui: Tweaks in naming (r_id_ptr and idpair_cb)

Jeroen Bakker noreply at git.blender.org
Tue Jan 25 10:14:29 CET 2022


Commit: 20f878546384c8b0bd42ee2e50c002664366fa57
Author: Jeroen Bakker
Date:   Tue Jan 25 10:14:00 2022 +0100
Branches: temp-T94185-id-remapper-ui
https://developer.blender.org/rB20f878546384c8b0bd42ee2e50c002664366fa57

Tweaks in naming (r_id_ptr and idpair_cb)

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

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

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

diff --git a/source/blender/blenkernel/BKE_lib_remap.h b/source/blender/blenkernel/BKE_lib_remap.h
index 24b645c6238..cc970342fbb 100644
--- a/source/blender/blenkernel/BKE_lib_remap.h
+++ b/source/blender/blenkernel/BKE_lib_remap.h
@@ -173,7 +173,7 @@ struct IDRemapper;
 typedef enum IDRemapperApplyResult {
   /** No remapping rules available for the source. */
   ID_REMAP_RESULT_SOURCE_UNAVAILABLE,
-  /** Source isn't mappable (fe NULL). */
+  /** Source isn't mappable (e.g. NULL). */
   ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE,
   /** Source has been remapped to a new pointer. */
   ID_REMAP_RESULT_SOURCE_REMAPPED,
@@ -207,10 +207,10 @@ void BKE_id_remapper_add(struct IDRemapper *id_remapper, struct ID *old_id, stru
 /**
  * Apply a remapping.
  *
- * Update the id pointer stored in the given id_ptr_ptr id a remapping rule exists.
+ * Update the id pointer stored in the given r_id_ptr if a remapping rule exists.
  */
 IDRemapperApplyResult BKE_id_remapper_apply(const struct IDRemapper *id_remapper,
-                                            struct ID **id_ptr_ptr,
+                                            struct ID **r_id_ptr,
                                             IDRemapperApplyOptions options);
 bool BKE_id_remapper_has_mapping_for(const struct IDRemapper *id_remapper, uint64_t type_filter);
 void BKE_id_remapper_iter(const struct IDRemapper *id_remapper,
diff --git a/source/blender/blenkernel/intern/lib_id_remapper.cc b/source/blender/blenkernel/intern/lib_id_remapper.cc
index a458bf9fadc..4bb6f44612c 100644
--- a/source/blender/blenkernel/intern/lib_id_remapper.cc
+++ b/source/blender/blenkernel/intern/lib_id_remapper.cc
@@ -49,6 +49,7 @@ struct IDRemapper {
   void add(ID *old_id, ID *new_id)
   {
     BLI_assert(old_id != nullptr);
+    BLI_assert(new_id != nullptr && GS(old_id) == GS(new_id));
     mappings.add(old_id, new_id);
     source_types |= BKE_idtype_idcode_to_idfilter(GS(old_id->name));
   }
@@ -58,32 +59,32 @@ struct IDRemapper {
     return (source_types & filter) != 0;
   }
 
-  IDRemapperApplyResult apply(ID **id_ptr_ptr, IDRemapperApplyOptions options) const
+  IDRemapperApplyResult apply(ID **r_id_ptr, IDRemapperApplyOptions options) const
   {
-    BLI_assert(id_ptr_ptr != nullptr);
-    if (*id_ptr_ptr == nullptr) {
+    BLI_assert(r_id_ptr != nullptr);
+    if (*r_id_ptr == nullptr) {
       return ID_REMAP_RESULT_SOURCE_NOT_MAPPABLE;
     }
 
-    if (!mappings.contains(*id_ptr_ptr)) {
+    if (!mappings.contains(*r_id_ptr)) {
       return ID_REMAP_RESULT_SOURCE_UNAVAILABLE;
     }
 
     if (options & ID_REMAP_APPLY_UPDATE_REFCOUNT) {
-      id_us_min(*id_ptr_ptr);
+      id_us_min(*r_id_ptr);
     }
 
-    *id_ptr_ptr = mappings.lookup(*id_ptr_ptr);
-    if (*id_ptr_ptr == nullptr) {
+    *r_id_ptr = mappings.lookup(*r_id_ptr);
+    if (*r_id_ptr == nullptr) {
       return ID_REMAP_RESULT_SOURCE_UNASSIGNED;
     }
 
     if (options & ID_REMAP_APPLY_UPDATE_REFCOUNT) {
-      id_us_plus(*id_ptr_ptr);
+      id_us_plus(*r_id_ptr);
     }
 
     if (options & ID_REMAP_APPLY_ENSURE_REAL) {
-      id_us_ensure_real(*id_ptr_ptr);
+      id_us_ensure_real(*r_id_ptr);
     }
     return ID_REMAP_RESULT_SOURCE_REMAPPED;
   }
@@ -157,11 +158,11 @@ bool BKE_id_remapper_has_mapping_for(const struct IDRemapper *id_remapper, uint6
 }
 
 IDRemapperApplyResult BKE_id_remapper_apply(const IDRemapper *id_remapper,
-                                            ID **id_ptr_ptr,
+                                            ID **r_id_ptr,
                                             const IDRemapperApplyOptions options)
 {
   const blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper);
-  return remapper->apply(id_ptr_ptr, options);
+  return remapper->apply(r_id_ptr, options);
 }
 
 void BKE_id_remapper_iter(const struct IDRemapper *id_remapper,
@@ -171,4 +172,4 @@ void BKE_id_remapper_iter(const struct IDRemapper *id_remapper,
   const blender::bke::id::remapper::IDRemapper *remapper = unwrap(id_remapper);
   remapper->iter(func, user_data);
 }
-}
\ No newline at end of file
+}
diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c
index 36fc61912ba..c3ccedb9608 100644
--- a/source/blender/blenkernel/intern/lib_remap.c
+++ b/source/blender/blenkernel/intern/lib_remap.c
@@ -515,7 +515,7 @@ typedef struct LibblockRemapMultipleUserData {
   short remap_flags;
 } LibBlockRemapMultipleUserData;
 
-static void libblock_remap_locked_ex(ID *old_id, ID *new_id, void *user_data)
+static void libblock_remap_foreach_idpair_cb(ID *old_id, ID *new_id, void *user_data)
 {
   LibBlockRemapMultipleUserData *data = user_data;
   Main *bmain = data->bmain;
@@ -618,7 +618,7 @@ void BKE_libblock_remap_multiple_locked(Main *bmain,
   LibBlockRemapMultipleUserData user_data;
   user_data.bmain = bmain;
   user_data.remap_flags = remap_flags;
-  BKE_id_remapper_iter(mappings, libblock_remap_locked_ex, &user_data);
+  BKE_id_remapper_iter(mappings, libblock_remap_foreach_idpair_cb, &user_data);
 
   /* We assume editors do not hold references to their IDs... This is false in some cases
    * (Image is especially tricky here),



More information about the Bf-blender-cvs mailing list