Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_rna.c
| Show First 20 Lines • Show All 1,273 Lines • ▼ Show 20 Lines | bool is_valid_for_diffing = rna_property_override_diff_propptr_validate_diffing(propptr_a, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| 0, | 0, | ||||
| NULL, | NULL, | ||||
| NULL, | NULL, | ||||
| 0); | 0); | ||||
| if (is_id) { | if (is_id) { | ||||
| /* For now, once we deal with nodetrees we'll want to get rid of that one. */ | /* Owned IDs (the ones we want to actually compare in depth, instead of just comparing pointer | ||||
| // BLI_assert(no_ownership); | * values) should be always properly tagged as 'virtual' overrides. */ | ||||
| ID *id = propptr_a->owner_id; | |||||
| if (id != NULL && !ID_IS_OVERRIDE_LIBRARY(id)) { | |||||
| id = propptr_b->owner_id; | |||||
| if (id != NULL && !ID_IS_OVERRIDE_LIBRARY(id)) { | |||||
| id = NULL; | |||||
| } | |||||
| } | |||||
| BLI_assert(no_ownership || id == NULL || ID_IS_OVERRIDE_LIBRARY_VIRTUAL(id)); | |||||
| UNUSED_VARS_NDEBUG(id); | |||||
| } | } | ||||
| if (override) { | if (override) { | ||||
| if (no_ownership /* || is_id */ || is_null || is_type_diff || !is_valid_for_diffing) { | if (no_ownership || is_null || is_type_diff || !is_valid_for_diffing) { | ||||
| /* In case this pointer prop does not own its data (or one is NULL), do not compare structs! | /* In case this pointer prop does not own its data (or one is NULL), do not compare structs! | ||||
| * This is a quite safe path to infinite loop, among other nasty issues. | * This is a quite safe path to infinite loop, among other nasty issues. | ||||
| * Instead, just compare pointers themselves. */ | * Instead, just compare pointers themselves. */ | ||||
| const int comp = (propptr_a->data != propptr_b->data); | const int comp = (propptr_a->data != propptr_b->data); | ||||
| if (do_create && comp != 0) { | if (do_create && comp != 0) { | ||||
| bool created = false; | bool created = false; | ||||
| IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get( | IDOverrideLibraryProperty *op = BKE_lib_override_library_property_get( | ||||
| override, rna_path, &created); | override, rna_path, &created); | ||||
| /* If not yet overridden, or if we are handling sub-items (inside a collection)... */ | /* If not yet overridden, or if we are handling sub-items (inside a collection)... */ | ||||
| if (op != NULL) { | if (op != NULL) { | ||||
| if (created || op->rna_prop_type == 0) { | if (created || op->rna_prop_type == 0) { | ||||
| op->rna_prop_type = property_type; | op->rna_prop_type = property_type; | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(op->rna_prop_type == property_type); | BLI_assert(op->rna_prop_type == property_type); | ||||
| } | } | ||||
| IDOverrideLibraryPropertyOperation *opop = NULL; | |||||
| if (created || rna_itemname_a != NULL || rna_itemname_b != NULL || | if (created || rna_itemname_a != NULL || rna_itemname_b != NULL || | ||||
| rna_itemindex_a != -1 || rna_itemindex_b != -1) { | rna_itemindex_a != -1 || rna_itemindex_b != -1) { | ||||
| IDOverrideLibraryPropertyOperation *opop; | |||||
| opop = BKE_lib_override_library_property_operation_get(op, | opop = BKE_lib_override_library_property_operation_get(op, | ||||
| IDOVERRIDE_LIBRARY_OP_REPLACE, | IDOVERRIDE_LIBRARY_OP_REPLACE, | ||||
| rna_itemname_b, | rna_itemname_b, | ||||
| rna_itemname_a, | rna_itemname_a, | ||||
| rna_itemindex_b, | rna_itemindex_b, | ||||
| rna_itemindex_a, | rna_itemindex_a, | ||||
| true, | true, | ||||
| NULL, | NULL, | ||||
| &created); | &created); | ||||
| /* Do not use BKE_lib_override_library_operations_tag here, we do not want to validate | /* Do not use BKE_lib_override_library_operations_tag here, we do not want to validate | ||||
| * as used all of its operations. */ | * as used all of its operations. */ | ||||
| op->tag &= ~IDOVERRIDE_LIBRARY_TAG_UNUSED; | op->tag &= ~IDOVERRIDE_LIBRARY_TAG_UNUSED; | ||||
| opop->tag &= ~IDOVERRIDE_LIBRARY_TAG_UNUSED; | opop->tag &= ~IDOVERRIDE_LIBRARY_TAG_UNUSED; | ||||
| if (r_override_changed) { | if (r_override_changed) { | ||||
| *r_override_changed = created; | *r_override_changed = created; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_lib_override_library_operations_tag(op, IDOVERRIDE_LIBRARY_TAG_UNUSED, false); | 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; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| return comp; | return comp; | ||||
| } | } | ||||
| else { | else { | ||||
| /* In case we got some array/collection like items identifiers, now is the time to generate a | /* In case we got some array/collection like items identifiers, now is the time to generate a | ||||
| * proper rna path from those. */ | * proper rna path from those. */ | ||||
| ▲ Show 20 Lines • Show All 1,945 Lines • Show Last 20 Lines | |||||