From c79642fa98340500d9e44653be7d28c075b50bb9 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 23 Aug 2023 11:39:47 +0200 Subject: [PATCH] Core: foreach_id: Do not mutually exclude 'no origpointer access' and 'readonly' flags anymore. There are actually cases where you do not want to access the original ID pointers, even though the callback will not modify them. One example is the incoming generic 'expand' readfile callback, which will replace the dedicated one for all ID types. Related to #105134: Removal of readfile's lib_link & expand code. --- source/blender/blenkernel/BKE_lib_query.h | 5 ++--- source/blender/blenkernel/intern/lib_query.cc | 7 ++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/source/blender/blenkernel/BKE_lib_query.h b/source/blender/blenkernel/BKE_lib_query.h index 04fbb70a374..8cec5d958a9 100644 --- a/source/blender/blenkernel/BKE_lib_query.h +++ b/source/blender/blenkernel/BKE_lib_query.h @@ -175,9 +175,8 @@ enum { * \note Access to owning embedded ID pointers (e.g. `Scene.master_collection`) is not affected * here, these are presumed always valid. * - * \note This flag is mutually exclusive with `IDWALK_READONLY` and `IDWALK_RECURSE`, since by - * definition the only thing doable in readonly case is accessing current ID pointer, and this is - * also required for recursion. + * \note This flag is mutually exclusive with `IDWALK_RECURSE`, since by definition accessing the + * current ID pointer is required for recursion. * * \note After remapping, code may access the newly set ID pointer, which is always presumed * valid. diff --git a/source/blender/blenkernel/intern/lib_query.cc b/source/blender/blenkernel/intern/lib_query.cc index 8e9eca1bbac..7e2b2e88efe 100644 --- a/source/blender/blenkernel/intern/lib_query.cc +++ b/source/blender/blenkernel/intern/lib_query.cc @@ -148,7 +148,7 @@ void BKE_lib_query_idpropertiesForeachIDLink_callback(IDProperty *id_prop, void void BKE_library_foreach_ID_embedded(LibraryForeachIDData *data, ID **id_pp) { - /* Needed e.g. for callbacks handling relationships. This call shall be absolutely read-only. */ + /* Needed e.g. for callbacks handling relationships. This call should be absolutely read-only. */ ID *id = *id_pp; const int flag = data->flag; @@ -205,10 +205,7 @@ static bool library_foreach_ID_link(Main *bmain, data.bmain = bmain; BLI_assert(inherit_data == nullptr || data.bmain == inherit_data->bmain); - /* `IDWALK_NO_ORIG_POINTERS_ACCESS` is mutually exclusive with both `IDWALK_READONLY` and - * `IDWALK_RECURSE`. */ - BLI_assert((flag & (IDWALK_NO_ORIG_POINTERS_ACCESS | IDWALK_READONLY)) != - (IDWALK_NO_ORIG_POINTERS_ACCESS | IDWALK_READONLY)); + /* `IDWALK_NO_ORIG_POINTERS_ACCESS` is mutually exclusive with `IDWALK_RECURSE`. */ BLI_assert((flag & (IDWALK_NO_ORIG_POINTERS_ACCESS | IDWALK_RECURSE)) != (IDWALK_NO_ORIG_POINTERS_ACCESS | IDWALK_RECURSE));