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`.
This commit is contained in:
Bastien Montagne 2024-03-05 11:53:06 +01:00
parent 521e6e4467
commit 1906ee76ba
1 changed files with 10 additions and 8 deletions

View File

@ -10,6 +10,7 @@
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <optional>
#include <sstream>
#include <fmt/format.h>
@ -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<PropertyRNA *> 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<PointerRNA *>(ptr), prop);
return rna_property_editable_do(ptr, prop_orig, prop_ensured, -1, nullptr);
}
bool RNA_property_drivable(const PointerRNA *ptr, PropertyRNA *prop)