diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-05-01 16:08:38 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-05-01 16:08:38 +0300 |
commit | 3166086c6000495e42a6aa01c25e1a66c52185bd (patch) | |
tree | c493e3de17fd420a387ebe0aa400cc85085b8967 /source/blender | |
parent | 008a5d9106bf1226c2cd506d7897443891b5c261 (diff) |
Static Override: fix 'search matching override operation' function.
Previous code was waaaayyyy to flacky, returning matches for things that
did not actually have much in common!
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/library_override.c | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/source/blender/blenkernel/intern/library_override.c b/source/blender/blenkernel/intern/library_override.c index 625af190bbc..8917fac198c 100644 --- a/source/blender/blenkernel/intern/library_override.c +++ b/source/blender/blenkernel/intern/library_override.c @@ -28,6 +28,7 @@ */ #include <stdlib.h> +#include <string.h> #include "MEM_guardedalloc.h" @@ -303,30 +304,46 @@ IDOverrideStaticPropertyOperation *BKE_override_static_property_operation_find( *r_strict = true; } - if (subitem_locname && - (opop = BLI_findstring_ptr(&override_property->operations, subitem_locname, - offsetof(IDOverrideStaticPropertyOperation, subitem_local_name)))) - { - return opop; + if (subitem_locname != NULL) { + opop = BLI_findstring_ptr(&override_property->operations, subitem_locname, + offsetof(IDOverrideStaticPropertyOperation, subitem_local_name)); + + if (opop == NULL) { + return NULL; + } + + if (subitem_refname == NULL || opop->subitem_reference_name == NULL) { + return subitem_refname == opop->subitem_reference_name ? opop : NULL; + } + return (subitem_refname != NULL && opop->subitem_reference_name != NULL && + STREQ(subitem_refname, opop->subitem_reference_name)) ? opop : NULL; } - if (subitem_refname && - (opop = BLI_findstring_ptr(&override_property->operations, subitem_refname, - offsetof(IDOverrideStaticPropertyOperation, subitem_reference_name)))) - { - return opop; + if (subitem_refname != NULL) { + opop = BLI_findstring_ptr(&override_property->operations, subitem_refname, + offsetof(IDOverrideStaticPropertyOperation, subitem_reference_name)); + + if (opop == NULL) { + return NULL; + } + + if (subitem_locname == NULL || opop->subitem_local_name == NULL) { + return subitem_locname == opop->subitem_local_name ? opop : NULL; + } + return (subitem_locname != NULL && opop->subitem_local_name != NULL && + STREQ(subitem_locname, opop->subitem_local_name)) ? opop : NULL; } if ((opop = BLI_listbase_bytes_find(&override_property->operations, &subitem_locindex, sizeof(subitem_locindex), offsetof(IDOverrideStaticPropertyOperation, subitem_local_index)))) { - return opop; + return ELEM(subitem_refindex, -1, opop->subitem_reference_index) ? opop : NULL; } if ((opop = BLI_listbase_bytes_find(&override_property->operations, &subitem_refindex, sizeof(subitem_refindex), offsetof(IDOverrideStaticPropertyOperation, subitem_reference_index)))) { - return opop; + return ELEM(subitem_locindex, -1, opop->subitem_local_index) ? opop : NULL; } /* index == -1 means all indices, that is valid fallback in case we requested specific index. */ |