diff options
author | Bastien Montagne <bastien@blender.org> | 2021-03-12 14:31:25 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-03-12 14:31:25 +0300 |
commit | 74557ca4f7cfe14090d6ca245e03e651b4b2524f (patch) | |
tree | 72633e2f71ae235e54f60520b06de513a6bc5347 /source/blender/makesrna | |
parent | fe2ceef729a1a1013f7a8466318a12343a6a0e15 (diff) |
LibOverride: Add a new operation to Outliner to enforce resync of hierarchies.
This is basically done by ignoring override operations from old override
affecting ID pointer properties, when the new (destination) one is not
NULL.
Fix T86501: New object added to overridden collection doesn't show up in linking file on Resync.
This is more of a work-around actually, since there is no real way to
fix the issue in a fully automated and consistent way, it is caused by
older blender files being saved with 'broken' overrides.
WARNING: This cannot ensure that some purposedly edited/overridden ID
pointer properties won't be lost in the process.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 12 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access_compare_override.c | 36 |
2 files changed, 46 insertions, 2 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 74b8517f538..4c60ffe4f16 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -1512,11 +1512,21 @@ bool RNA_struct_override_store(struct Main *bmain, PointerRNA *ptr_storage, struct IDOverrideLibrary *override); +typedef enum eRNAOverrideApplyFlag { + RNA_OVERRIDE_APPLY_FLAG_NOP = 0, + /** + * Hack to work around/fix older broken overrides: Do not apply override operations affecting ID + * pointers properties, unless the destination original value (the one being overridden) is NULL. + */ + RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS = 1 << 0, +} eRNAOverrideApplyFlag; + void RNA_struct_override_apply(struct Main *bmain, struct PointerRNA *ptr_dst, struct PointerRNA *ptr_src, struct PointerRNA *ptr_storage, - struct IDOverrideLibrary *override); + struct IDOverrideLibrary *override, + const eRNAOverrideApplyFlag flag); struct IDOverrideLibraryProperty *RNA_property_override_property_find(struct Main *bmain, PointerRNA *ptr, diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index 6a8152d1139..28d4cc4d075 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -1123,7 +1123,8 @@ void RNA_struct_override_apply(Main *bmain, PointerRNA *ptr_dst, PointerRNA *ptr_src, PointerRNA *ptr_storage, - IDOverrideLibrary *override) + IDOverrideLibrary *override, + const eRNAOverrideApplyFlag flag) { #ifdef DEBUG_OVERRIDE_TIMEIT TIMEIT_START_AVERAGED(RNA_struct_override_apply); @@ -1187,6 +1188,39 @@ void RNA_struct_override_apply(Main *bmain, } } + /* Workaround for older broken overrides, we then assume that non-matching ID pointers + * override operations that replace a non-NULL value are 'mistakes', and ignore (do not + * apply) them. */ + if ((flag & RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS) != 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_dst = RNA_property_pointer_get(&data_dst, prop_dst); + if (prop_ptr_dst.type != NULL && RNA_struct_is_ID(prop_ptr_dst.type)) { +#ifndef NDEBUG + PointerRNA prop_ptr_src = RNA_property_pointer_get(&data_src, prop_src); + BLI_assert(prop_ptr_src.type == NULL || RNA_struct_is_ID(prop_ptr_src.type)); +#endif + ID *id_dst = rna_property_override_property_real_id_owner( + bmain, &prop_ptr_dst, NULL, NULL); + + if (id_dst != NULL) { + CLOG_INFO(&LOG, + 3, + "%s: Ignoring local override on ID pointer property '%s', as requested by " + "RNA_OVERRIDE_APPLY_FLAG_IGNORE_ID_POINTERS flag", + ptr_dst->owner_id->name, + op->rna_path); + continue; + } + } + } + rna_property_override_apply_ex(bmain, &data_dst, &data_src, |