diff options
author | Bastien Montagne <bastien@blender.org> | 2020-12-31 20:03:45 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-03-11 16:26:19 +0300 |
commit | 534f4e90fd62dab3a19228219c69cb3f065c6f43 (patch) | |
tree | 0a0e723e8011c2a3b8be450a262a1e1724143c97 /source/blender/makesrna/intern/rna_access_compare_override.c | |
parent | 96064c3bb7d135ab69eb4a146c173dc4a36db1cc (diff) |
LibOverride: First stage of detection of 'need resync'.
We can fairly easily detect some resync-needed cases when applying the
overrides operations on a Pointer RNA property.
This should cover all cases where an existing override's ID pointer is
changed in its linked data.
We still have to add code to detect when a not-yet-overridden linked ID
needs to become overridden (because its relations to other data-blocks
changed in a way that requires it).
Part of T83811 & D10649.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access_compare_override.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access_compare_override.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 0f3b0a895db..6a8152d1139 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -61,7 +61,7 @@ static CLG_LogRef LOG = {"rna.access_compare_override"}; * Find the actual ID owner of the given \a ptr #PointerRNA, in override sense, and generate the * full rna path from it to given \a prop #PropertyRNA if \a rna_path is given. * - * \note this is slightly different than 'generic' RNA 'id owner' as returned by + * \note This is slightly different than 'generic' RNA 'id owner' as returned by * #RNA_find_real_ID_and_path, since in overrides we also consider shape keys as embedded data, not * only root node trees and master collections. */ @@ -104,10 +104,6 @@ static ID *rna_property_override_property_real_id_owner(Main *bmain, } } - if (!ID_IS_OVERRIDE_LIBRARY_REAL(owner_id)) { - return NULL; - } - if (r_rna_path == NULL) { return owner_id; } @@ -1158,6 +1154,39 @@ void RNA_struct_override_apply(Main *bmain, ptr_storage, op->rna_path, &data_storage, &prop_storage, &data_item_storage); } + /* Check if an overridden ID pointer supposed to be in sync with linked data gets out of + * sync. */ + if ((ptr_dst->owner_id->tag & LIB_TAG_LIB_OVERRIDE_NEED_RESYNC) == 0 && + op->rna_prop_type == PROP_POINTER && + (((IDOverrideLibraryPropertyOperation *)op->operations.first)->flag & + IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) != 0) { + BLI_assert(ptr_src->owner_id == + rna_property_override_property_real_id_owner(bmain, &data_src, NULL, NULL)); + BLI_assert(ptr_dst->owner_id == + rna_property_override_property_real_id_owner(bmain, &data_dst, NULL, NULL)); + + PointerRNA prop_ptr_src = RNA_property_pointer_get(&data_src, prop_src); + PointerRNA prop_ptr_dst = RNA_property_pointer_get(&data_dst, prop_dst); + ID *id_src = rna_property_override_property_real_id_owner( + bmain, &prop_ptr_src, NULL, NULL); + ID *id_dst = rna_property_override_property_real_id_owner( + bmain, &prop_ptr_dst, NULL, NULL); + + BLI_assert(id_src == NULL || ID_IS_OVERRIDE_LIBRARY_REAL(id_src)); + + if (/* We might be in a case where id_dst has already been processed and its usages + * remapped to its new local override. In that case overrides and linked data are + * always properly matching. */ + id_src != id_dst && + /* If one of the pointers is NULL and not the other, or if linked reference ID of + * `id_src` is not `id_dst`, we are in a non-matching case. */ + (ELEM(NULL, id_src, id_dst) || id_src->override_library->reference != id_dst)) { + ptr_dst->owner_id->tag |= LIB_TAG_LIB_OVERRIDE_NEED_RESYNC; + CLOG_INFO( + &LOG, 3, "Local override %s detected as needing resync", ptr_dst->owner_id->name); + } + } + rna_property_override_apply_ex(bmain, &data_dst, &data_src, |