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.
This commit is contained in:
Bastien Montagne 2021-11-01 14:42:56 +01:00
parent 64de6ad4fe
commit e85e126e3f
Notes: blender-bot 2023-02-13 17:16:25 +01:00
Referenced by issue #92629, Crash on mesh separate
2 changed files with 8 additions and 1 deletions

View File

@ -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,

View File

@ -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;