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.
This commit is contained in:
Bastien Montagne
2023-08-23 11:39:47 +02:00
parent e7abe1fd76
commit c79642fa98
2 changed files with 4 additions and 8 deletions
+2 -3
View File
@@ -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.
@@ -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));