Depsgraph: Fix wrong access to animated properties

Copy-on-write backuyp was trying to read float from an array property,
which is wrong.

This is part of T73029.
This commit is contained in:
Sergey Sharybin 2020-01-13 12:03:01 +01:00
parent 9d254fa17a
commit 3c1115ef7f
2 changed files with 11 additions and 14 deletions

View File

@ -59,11 +59,8 @@ void animated_property_store_cb(ID *id, FCurve *fcurve, void *data_v)
/* Resolve path to the property. */
PathResolvedRNA resolved_rna;
if (!RNA_path_resolve_property_full(&data->id_pointer_rna,
fcurve->rna_path,
&resolved_rna.ptr,
&resolved_rna.prop,
&resolved_rna.prop_index)) {
if (!BKE_animsys_store_rna_setting(
&data->id_pointer_rna, fcurve->rna_path, fcurve->array_index, &resolved_rna)) {
return;
}
@ -73,7 +70,7 @@ void animated_property_store_cb(ID *id, FCurve *fcurve, void *data_v)
return;
}
data->backup->values_backup.emplace_back(fcurve->rna_path, value);
data->backup->values_backup.emplace_back(fcurve->rna_path, fcurve->array_index, value);
}
} // namespace
@ -82,8 +79,8 @@ AnimationValueBackup::AnimationValueBackup()
{
}
AnimationValueBackup::AnimationValueBackup(const string &rna_path, float value)
: rna_path(rna_path), value(value)
AnimationValueBackup::AnimationValueBackup(const string &rna_path, int array_index, float value)
: rna_path(rna_path), array_index(array_index), value(value)
{
}
@ -121,11 +118,10 @@ void AnimationBackup::restore_to_id(ID *id)
* changed after copy-on-write.
*/
PathResolvedRNA resolved_rna;
if (!RNA_path_resolve_property_full(&id_pointer_rna,
value_backup.rna_path.c_str(),
&resolved_rna.ptr,
&resolved_rna.prop,
&resolved_rna.prop_index)) {
if (!BKE_animsys_store_rna_setting(&id_pointer_rna,
value_backup.rna_path.c_str(),
value_backup.array_index,
&resolved_rna)) {
return;
}

View File

@ -34,7 +34,7 @@ struct Depsgraph;
class AnimationValueBackup {
public:
AnimationValueBackup();
AnimationValueBackup(const string &rna_path, float value);
AnimationValueBackup(const string &rna_path, int array_index, float value);
~AnimationValueBackup();
AnimationValueBackup(const AnimationValueBackup &other) = default;
@ -44,6 +44,7 @@ class AnimationValueBackup {
AnimationValueBackup &operator=(AnimationValueBackup &&other) = default;
string rna_path;
int array_index;
float value;
};