diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-10-03 21:29:38 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-10-04 13:27:10 +0300 |
commit | ba10cd49220a778014fa2e77eff45c32ca106fbe (patch) | |
tree | bd251ca1d362e377ec143ee829a9fe8ae85d8fcf /source/blender/makesrna | |
parent | 837653d735249a65ccdd7467625041493a14cc8a (diff) |
LibOverride: Fix last main issue with overriding custom properties.
Now, custom props defined as overriddable can be overridden, saved,
reloaded, etc. That fixes the last main issue with them.
Note that custom props still have a lot of glitches and weirdness in
their overriding behavior, but for now the most important is finally
achieved, will let them rest and settle a bit, those have been
incredibly painful to tame... :(
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access_compare_override.c | 15 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access_internal.h | 1 |
3 files changed, 17 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 71a3be24810..aeb6d528cdb 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -393,7 +393,7 @@ bool RNA_struct_idprops_check(StructRNA *srna) return (srna && srna->idproperties); } -static IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name) +IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name) { IDProperty *group = RNA_struct_idprops(ptr, 0); diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index df1554ac7bc..18fbe7886e9 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -625,6 +625,21 @@ bool RNA_struct_override_matches(Main *bmain, prop_local = rna_ensure_property_realdata(&prop_local, ptr_local); prop_reference = rna_ensure_property_realdata(&prop_reference, ptr_reference); + /* IDProps (custom properties) are even more of a PITA here, we cannot use + * `rna_ensure_property_realdata()` to deal with them, we have to use the path generated from + * `prop_local` (which is valid) to access to the actual reference counterpart... */ + if (prop_local != NULL && prop_local->magic != RNA_MAGIC && prop_local == prop_reference) { + /* We could also use (lower in this code, after rna_path has been computed): + * RNA_path_resolve_property(ptr_reference, rna_path, &some_rna_ptr, &prop_reference); + * But that would be much more costly, and would also fail when ptr_reference + * is not an ID pointer itself, so we'd need to rebuild it from its owner_id, then check that + * generated some_rna_ptr and ptr_reference do point to the same data, etc. + * For now, let's try that simple access, it won't cover all cases but should handle fine + * most basic custom properties situations. */ + prop_reference = (PropertyRNA *)rna_idproperty_find(ptr_reference, + ((IDProperty *)prop_local)->name); + } + if (ELEM(NULL, prop_local, prop_reference)) { continue; } diff --git a/source/blender/makesrna/intern/rna_access_internal.h b/source/blender/makesrna/intern/rna_access_internal.h index 28ec504e376..c7995746d08 100644 --- a/source/blender/makesrna/intern/rna_access_internal.h +++ b/source/blender/makesrna/intern/rna_access_internal.h @@ -30,5 +30,6 @@ struct IDProperty; PropertyRNA *rna_ensure_property(PropertyRNA *prop); void rna_idproperty_touch(struct IDProperty *idprop); +struct IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name); #endif /* __ACCESS_RNA_INTERNAL_H__ */ |