LibOverride/LibQuery: Refactor 'non-overridable' status management.
Move the detection/decision of whether an ID pointer should be taken into account in library override hierarchy processing to the LibQuery area of code, by introducing a new callback flag. This allows to factorize the test logic, be explicit in liboverride code about ID relationships that can be ignored when exploring the override hierarchy, and adds the possibility to do more checks about pointers to be tagged as non-overridable in the future. Note that all but the 'special' ID pointers (loop-back, embedded, etc.) should be overridable. If some is not, relevant IDType 'foreach_id' callback code is reponsible to tag it properly. Python-defined IDProperties however are not systematicaly overridable (yet), so this should allow us to detect that case and act accordingly in an incomming commit. No behavioral change expected in this commit.
This commit is contained in:
@@ -70,12 +70,15 @@ enum {
|
||||
/** That ID is used as library override's reference by its owner. */
|
||||
IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE = (1 << 5),
|
||||
|
||||
/** That ID pointer is not overridable. */
|
||||
IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE = (1 << 6),
|
||||
|
||||
/**
|
||||
* Indicates that this is an internal runtime ID pointer, like e.g. `ID.newid` or `ID.original`.
|
||||
* \note Those should be ignored in most cases, and won't be processed/generated anyway unless
|
||||
* `IDWALK_DO_INTERNAL_RUNTIME_POINTERS` option is enabled.
|
||||
*/
|
||||
IDWALK_CB_INTERNAL = (1 << 6),
|
||||
IDWALK_CB_INTERNAL = (1 << 7),
|
||||
|
||||
/**
|
||||
* This ID usage is fully refcounted.
|
||||
|
||||
@@ -480,10 +480,8 @@ static void lib_override_linked_group_tag_recursive(LibOverrideGroupTagData *dat
|
||||
|
||||
for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL;
|
||||
to_id_entry = to_id_entry->next) {
|
||||
if ((to_id_entry->usage_flag &
|
||||
(IDWALK_CB_EMBEDDED | IDWALK_CB_LOOPBACK | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) != 0) {
|
||||
/* Never consider 'loop back' relationships ('from', 'parents', 'owner' etc. pointers), nor
|
||||
* override references or embedded ID pointers, as actual dependencies. */
|
||||
if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) {
|
||||
/* Never consider non-overridable relationships as actual dependencies. */
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -578,10 +576,8 @@ static void lib_override_local_group_tag_recursive(LibOverrideGroupTagData *data
|
||||
|
||||
for (MainIDRelationsEntryItem *to_id_entry = entry->to_ids; to_id_entry != NULL;
|
||||
to_id_entry = to_id_entry->next) {
|
||||
if ((to_id_entry->usage_flag &
|
||||
(IDWALK_CB_EMBEDDED | IDWALK_CB_LOOPBACK | IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) != 0) {
|
||||
/* Never consider 'loop back' relationships ('from', 'parents', 'owner' etc. pointers), nor
|
||||
* override references or embedded ID pointers, as actual dependencies. */
|
||||
if ((to_id_entry->usage_flag & IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE) != 0) {
|
||||
/* Never consider non-overridable relationships as actual dependencies. */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,13 +73,25 @@ bool BKE_lib_query_foreachid_process(LibraryForeachIDData *data, ID **id_pp, int
|
||||
if (!(data->status & IDWALK_STOP)) {
|
||||
const int flag = data->flag;
|
||||
ID *old_id = *id_pp;
|
||||
const int callback_return = data->callback(&(struct LibraryIDLinkCallbackData){
|
||||
.user_data = data->user_data,
|
||||
.bmain = data->bmain,
|
||||
.id_owner = data->owner_id,
|
||||
.id_self = data->self_id,
|
||||
.id_pointer = id_pp,
|
||||
.cb_flag = ((cb_flag | data->cb_flag) & ~data->cb_flag_clear)});
|
||||
|
||||
/* Update the callback flags with the ones defined (or forbidden) in `data` by the generic
|
||||
* caller code. */
|
||||
cb_flag = ((cb_flag | data->cb_flag) & ~data->cb_flag_clear);
|
||||
|
||||
/* Update the callback flags with some extra information regarding overrides: all 'loopback',
|
||||
* 'internal', 'embedded' etc. ID pointers are never overridable. */
|
||||
if (cb_flag & (IDWALK_CB_INTERNAL | IDWALK_CB_EMBEDDED | IDWALK_CB_LOOPBACK |
|
||||
IDWALK_CB_OVERRIDE_LIBRARY_REFERENCE)) {
|
||||
cb_flag |= IDWALK_CB_OVERRIDE_LIBRARY_NOT_OVERRIDABLE;
|
||||
}
|
||||
|
||||
const int callback_return = data->callback(
|
||||
&(struct LibraryIDLinkCallbackData){.user_data = data->user_data,
|
||||
.bmain = data->bmain,
|
||||
.id_owner = data->owner_id,
|
||||
.id_self = data->self_id,
|
||||
.id_pointer = id_pp,
|
||||
.cb_flag = cb_flag});
|
||||
if (flag & IDWALK_READONLY) {
|
||||
BLI_assert(*(id_pp) == old_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user