diff options
author | Bastien Montagne <bastien@blender.org> | 2020-12-24 20:11:46 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2021-01-25 16:48:51 +0300 |
commit | 2a81d948ad00c5099ecdbdf2505c8732c99a1fba (patch) | |
tree | eb48ff9dc8f1b0d8ef44f06d18d962af417762f1 /source/blender/makesrna/intern/rna_rna.c | |
parent | 5c490bcbc82b43487f2e08978b69f1900e8bfce5 (diff) |
LibOverride: refactor of relationships handling in library overrides.
First step towards a better handling of relationships between IDs in
override context, especially when a resync is needed.
First, introduce a new flag to override operations,
`IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE`, for ID pointers.
It keeps track of whether an RNA ID pointer has been kept to its
'natural overriden ID' (in override hierarchy context), or has actually
been re-assigned to some other data-block.
Second, refactor how we deal with relationships between IDs in override
hierarchy code, especially in resync case. This will fixe several cases
listed in T83811, especially the case where an ID pointer to an existing
override needs to be updated to a new one due to a matching change in
linked data.
Diffstat (limited to 'source/blender/makesrna/intern/rna_rna.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 826e1202efc..cad0d77607b 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -1314,9 +1314,9 @@ static int rna_property_override_diff_propptr(Main *bmain, BLI_assert(op->rna_prop_type == property_type); } + IDOverrideLibraryPropertyOperation *opop = NULL; if (created || rna_itemname_a != NULL || rna_itemname_b != NULL || rna_itemindex_a != -1 || rna_itemindex_b != -1) { - IDOverrideLibraryPropertyOperation *opop; opop = BKE_lib_override_library_property_operation_get(op, IDOVERRIDE_LIBRARY_OP_REPLACE, rna_itemname_b, @@ -1337,6 +1337,38 @@ static int rna_property_override_diff_propptr(Main *bmain, else { BKE_lib_override_library_operations_tag(op, IDOVERRIDE_LIBRARY_TAG_UNUSED, false); } + + if (is_id && no_ownership) { + if (opop == NULL) { + opop = BKE_lib_override_library_property_operation_find(op, + rna_itemname_b, + rna_itemname_a, + rna_itemindex_b, + rna_itemindex_a, + true, + NULL); + BLI_assert(opop != NULL); + } + + BLI_assert(propptr_a->data == propptr_a->owner_id); + BLI_assert(propptr_b->data == propptr_b->owner_id); + ID *id_a = propptr_a->data; + ID *id_b = propptr_b->data; + if (ELEM(NULL, id_a, id_b)) { + /* In case one of the pointer is NULL and not the other, we consider that the + * override is not matching its reference anymore. */ + opop->flag &= ~IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE; + } + else if (id_a->override_library != NULL && id_a->override_library->reference == id_b) { + opop->flag |= IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE; + } + else if (id_b->override_library != NULL && id_b->override_library->reference == id_a) { + opop->flag |= IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE; + } + else { + opop->flag &= ~IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE; + } + } } } |