diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2019-09-24 18:21:21 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2019-09-25 15:27:47 +0300 |
commit | 1201352217a8cd3072eea3a1109a8a19915be14d (patch) | |
tree | b403d0517b968f87c7c69434d272f70b08071bd1 /source/blender/makesrna | |
parent | ef60cf8fca6a0f51eaf7adbcea2e644628e3049e (diff) |
LibOverride: Fix several issues in handling of overridable status for IDProps.
The triple possible status of an PropertyRNA (actual C-defined prop,
py-defined IDprop behaving similar ot RNA one, or actual 'pure' custom
prop) is really confusing... Not to mention the _RNA_UI ugly thingy on
top of that. :/
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 22 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access_compare_override.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 5 |
3 files changed, 19 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 6e98b5f4727..f412930f603 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -2081,15 +2081,15 @@ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char * ID *id = ptr->owner_id; int flag; - prop = rna_ensure_property(prop); + PropertyRNA *prop_type = rna_ensure_property(prop); *r_info = ""; /* get flag */ - if (prop->editable) { - flag = prop->editable(ptr, r_info); + if (prop_type->editable) { + flag = prop_type->editable(ptr, r_info); } else { - flag = prop->flag; + flag = prop_type->flag; if ((flag & PROP_EDITABLE) == 0 || (flag & PROP_REGISTER)) { *r_info = N_("This property is for internal use only and can't be edited"); } @@ -2097,17 +2097,21 @@ bool RNA_property_editable_info(PointerRNA *ptr, PropertyRNA *prop, const char * /* property from linked data-block */ if (id) { - if (ID_IS_LINKED(id) && (prop->flag & PROP_LIB_EXCEPTION) == 0) { + if (ID_IS_LINKED(id) && (prop_type->flag & PROP_LIB_EXCEPTION) == 0) { if (!(*r_info)[0]) { *r_info = N_("Can't edit this property from a linked data-block"); } return false; } - if (id->override_library != NULL && !RNA_property_overridable_get(ptr, prop)) { - if (!(*r_info)[0]) { - *r_info = N_("Can't edit this property from an override data-block"); + if (id->override_library != NULL) { + /* We need the real data property in case of IDProperty here... */ + PropertyRNA *real_prop = rna_ensure_property_realdata(&prop, ptr); + if (real_prop == NULL || !RNA_property_overridable_get(ptr, real_prop)) { + if (!(*r_info)[0]) { + *r_info = N_("Can't edit this property from an override data-block"); + } + return false; } - return false; } } diff --git a/source/blender/makesrna/intern/rna_access_compare_override.c b/source/blender/makesrna/intern/rna_access_compare_override.c index b0a83ea38c6..b061c72157e 100644 --- a/source/blender/makesrna/intern/rna_access_compare_override.c +++ b/source/blender/makesrna/intern/rna_access_compare_override.c @@ -76,8 +76,8 @@ bool RNA_property_overridable_get(PointerRNA *ptr, PropertyRNA *prop) } else { /* If this is a real 'pure' IDProp (aka custom property), we want to use the IDProp flag. */ - return !(prop->flag_override & PROPOVERRIDE_NO_COMPARISON) && - (((IDProperty *)prop)->flag & IDP_FLAG_OVERRIDABLE_LIBRARY); + IDProperty *idprop = (IDProperty *)prop; + return (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0; } } diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 6e21d02c0b3..26c8df4c7bb 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -613,7 +613,10 @@ static bool rna_Property_overridable_get(PointerRNA *ptr) { PropertyRNA *prop = (PropertyRNA *)ptr->data; - return (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_LIBRARY) != 0; + IDProperty *idprop = rna_idproperty_check(&prop, ptr); + + return idprop != NULL ? (idprop->flag & IDP_FLAG_OVERRIDABLE_LIBRARY) != 0 : + (prop->flag_override & PROPOVERRIDE_OVERRIDABLE_LIBRARY) != 0; } static bool rna_Property_use_output_get(PointerRNA *ptr) |