[Bf-blender-cvs] [e85e126e3f5] master: IDRemap: Add option to force remapping obdata in edit mode.

Bastien Montagne noreply at git.blender.org
Mon Nov 1 15:46:34 CET 2021


Commit: e85e126e3f52723da62b258cc9b196a9f15e34fd
Author: Bastien Montagne
Date:   Mon Nov 1 14:42:56 2021 +0100
Branches: master
https://developer.blender.org/rBe85e126e3f52723da62b258cc9b196a9f15e34fd

IDRemap: Add option to force remapping obdata in edit mode.

In theory we should never allow remapping of Objects' obdata ID pointer
when the object is in Edit mode. But there are some cases were this is
needed, so adding yet another exception option to remapping flags.

Preliminary change to fix T92629.

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

M	source/blender/blenkernel/BKE_lib_remap.h
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 8df6a803358..b05f3ef60df 100644
--- a/source/blender/blenkernel/BKE_lib_remap.h
+++ b/source/blender/blenkernel/BKE_lib_remap.h
@@ -89,6 +89,12 @@ enum {
    * dealing with IDs temporarily out of Main, but which will be put in it ultimately).
    */
   ID_REMAP_FORCE_USER_REFCOUNT = 1 << 8,
+  /**
+   * Force obdata pointers to also be processed, even when object (`id_owner`) is in Edit mode.
+   * This is required by some tools creating/deleting IDs while operating in Edit mode, like e.g.
+   * the 'separate' mesh operator.
+   */
+  ID_REMAP_FORCE_OBDATA_IN_EDITMODE = 1 << 9,
 };
 
 /* NOTE: Requiring new_id to be non-null, this *may* not be the case ultimately,
diff --git a/source/blender/blenkernel/intern/lib_remap.c b/source/blender/blenkernel/intern/lib_remap.c
index 248d85bcae0..15cc9d3c653 100644
--- a/source/blender/blenkernel/intern/lib_remap.c
+++ b/source/blender/blenkernel/intern/lib_remap.c
@@ -132,7 +132,8 @@ static int foreach_libblock_remap_callback(LibraryIDLinkCallbackData *cb_data)
     const bool is_obj = (GS(id_owner->name) == ID_OB);
     const bool is_obj_proxy = (is_obj &&
                                (((Object *)id_owner)->proxy || ((Object *)id_owner)->proxy_group));
-    const bool is_obj_editmode = (is_obj && BKE_object_is_in_editmode((Object *)id_owner));
+    const bool is_obj_editmode = (is_obj && BKE_object_is_in_editmode((Object *)id_owner) &&
+                                  (id_remap_data->flag & ID_REMAP_FORCE_OBDATA_IN_EDITMODE) == 0);
     const bool is_never_null = ((cb_flag & IDWALK_CB_NEVER_NULL) && (new_id == NULL) &&
                                 (id_remap_data->flag & ID_REMAP_FORCE_NEVER_NULL_USAGE) == 0);
     const bool skip_reference = (id_remap_data->flag & ID_REMAP_SKIP_OVERRIDE_LIBRARY) != 0;



More information about the Bf-blender-cvs mailing list