From 1906ee76bacfa91a223bc5578142955a0751ae86 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Tue, 5 Mar 2024 11:53:06 +0100 Subject: [PATCH] Fix (studio-reported) IDproperties of liboverrides not being animatable. Regression from 427eed292d, in IDProperty case the 'ensured' PropertyRNA pointer is some sort of empty template, and cannot be used for many things. Instead of calling `rna_ensure_property` twice for each call to `RNA_property_animateable`, rather add an optional parameter to static helper `rna_property_editable_do`, and call it directly from `RNA_property_animateable`. --- source/blender/makesrna/intern/rna_access.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/blender/makesrna/intern/rna_access.cc b/source/blender/makesrna/intern/rna_access.cc index d63a6e6e6ad..00435c3ed34 100644 --- a/source/blender/makesrna/intern/rna_access.cc +++ b/source/blender/makesrna/intern/rna_access.cc @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -2099,12 +2100,13 @@ int RNA_property_ui_icon(const PropertyRNA *prop) static bool rna_property_editable_do(const PointerRNA *ptr, PropertyRNA *prop_orig, + std::optional prop_ensured, const int index, const char **r_info) { ID *id = ptr->owner_id; - PropertyRNA *prop = rna_ensure_property(prop_orig); + PropertyRNA *prop = prop_ensured ? *prop_ensured : rna_ensure_property(prop_orig); const char *info = ""; const int flag = (prop->itemeditable != nullptr && index >= 0) ? @@ -2160,12 +2162,12 @@ static bool rna_property_editable_do(const PointerRNA *ptr, bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop) { - return rna_property_editable_do(ptr, prop, -1, nullptr); + return rna_property_editable_do(ptr, prop, std::nullopt, -1, nullptr); } bool RNA_property_editable_info(const PointerRNA *ptr, PropertyRNA *prop, const char **r_info) { - return rna_property_editable_do(ptr, prop, -1, r_info); + return rna_property_editable_do(ptr, prop, std::nullopt, -1, r_info); } bool RNA_property_editable_flag(const PointerRNA *ptr, PropertyRNA *prop) @@ -2182,10 +2184,10 @@ bool RNA_property_editable_index(const PointerRNA *ptr, PropertyRNA *prop, const { BLI_assert(index >= 0); - return rna_property_editable_do(ptr, prop, index, nullptr); + return rna_property_editable_do(ptr, prop, std::nullopt, index, nullptr); } -bool RNA_property_animateable(const PointerRNA *ptr, PropertyRNA *prop) +bool RNA_property_animateable(const PointerRNA *ptr, PropertyRNA *prop_orig) { /* check that base ID-block can support animation data */ if (!id_can_have_animdata(ptr->owner_id)) { @@ -2202,13 +2204,13 @@ bool RNA_property_animateable(const PointerRNA *ptr, PropertyRNA *prop) } } - prop = rna_ensure_property(prop); + PropertyRNA *prop_ensured = rna_ensure_property(prop_orig); - if (!(prop->flag & PROP_ANIMATABLE)) { + if (!(prop_ensured->flag & PROP_ANIMATABLE)) { return false; } - return RNA_property_editable(const_cast(ptr), prop); + return rna_property_editable_do(ptr, prop_orig, prop_ensured, -1, nullptr); } bool RNA_property_drivable(const PointerRNA *ptr, PropertyRNA *prop)