diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-08-16 17:19:52 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-08-16 17:25:52 +0300 |
commit | d8bb429964df170d27fe4a89e1c5ef754f0d018a (patch) | |
tree | aeaa9790244da2a1396c3117d3e79b3522e6daab /source/blender/makesrna/intern/rna_access.c | |
parent | d436d67fcc47b877da3844b5b1a441c5e6574c82 (diff) |
Fix T68651: LibOverride: Fix bad handling of RNA collections pointers.
We were storing the 'item' part in the RNA path of the override op
itself, which will not work with IDs because overriding local one might
not have the same name as the linked one (when some local ID with same
name already exists).
Now we are properly handling this using the expected actual override
operation, which stores necessary data (names or indices) from both
local and linked data.
Diffstat (limited to 'source/blender/makesrna/intern/rna_access.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 330d45c2fa5..b78a3304cc7 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -8860,6 +8860,80 @@ static void rna_property_override_apply_ex(Main *bmain, } continue; } + + /* Note: will have to think about putting that logic into its own function maybe? + * Would be nice to have it in a single place... */ + PointerRNA private_ptr_item_local, private_ptr_item_override, private_ptr_item_storage; + if (opop->subitem_local_name != NULL || opop->subitem_reference_name != NULL || + opop->subitem_local_index != -1 || opop->subitem_reference_index != -1) { + RNA_POINTER_INVALIDATE(&private_ptr_item_local); + RNA_POINTER_INVALIDATE(&private_ptr_item_override); + RNA_POINTER_INVALIDATE(&private_ptr_item_storage); + if (opop->subitem_local_name != NULL) { + RNA_property_collection_lookup_string( + ptr_local, prop_local, opop->subitem_local_name, &private_ptr_item_local); + if (opop->subitem_reference_name != NULL) { + RNA_property_collection_lookup_string(ptr_override, + prop_override, + opop->subitem_reference_name, + &private_ptr_item_override); + } + else { + RNA_property_collection_lookup_string( + ptr_override, prop_override, opop->subitem_local_name, &private_ptr_item_override); + } + } + else if (opop->subitem_reference_name != NULL) { + RNA_property_collection_lookup_string( + ptr_local, prop_local, opop->subitem_reference_name, &private_ptr_item_local); + RNA_property_collection_lookup_string( + ptr_override, prop_override, opop->subitem_reference_name, &private_ptr_item_override); + } + else if (opop->subitem_local_index != -1) { + RNA_property_collection_lookup_int( + ptr_local, prop_local, opop->subitem_local_index, &private_ptr_item_local); + if (opop->subitem_reference_index != -1) { + RNA_property_collection_lookup_int(ptr_override, + prop_override, + opop->subitem_reference_index, + &private_ptr_item_override); + } + else { + RNA_property_collection_lookup_int( + ptr_override, prop_override, opop->subitem_local_index, &private_ptr_item_override); + } + } + else if (opop->subitem_reference_index != -1) { + RNA_property_collection_lookup_int( + ptr_local, prop_local, opop->subitem_reference_index, &private_ptr_item_local); + RNA_property_collection_lookup_int(ptr_override, + prop_override, + opop->subitem_reference_index, + &private_ptr_item_override); + } + if (prop_storage != NULL) { + if (opop->subitem_local_name != NULL) { + RNA_property_collection_lookup_string( + ptr_storage, prop_storage, opop->subitem_local_name, &private_ptr_item_storage); + } + else if (opop->subitem_reference_name != NULL) { + RNA_property_collection_lookup_string( + ptr_storage, prop_storage, opop->subitem_reference_name, &private_ptr_item_storage); + } + else if (opop->subitem_local_index != -1) { + RNA_property_collection_lookup_int( + ptr_storage, prop_storage, opop->subitem_local_index, &private_ptr_item_storage); + } + else if (opop->subitem_reference_index != -1) { + RNA_property_collection_lookup_int( + ptr_storage, prop_storage, opop->subitem_reference_index, &private_ptr_item_storage); + } + } + ptr_item_local = &private_ptr_item_local; + ptr_item_override = &private_ptr_item_override; + ptr_item_storage = &private_ptr_item_storage; + } + if (!rna_property_override_operation_apply(bmain, ptr_local, ptr_override, |