Skip to content

Commit

Permalink
Avoid infinite recursion when AnimationPlayer.current_animation is se…
Browse files Browse the repository at this point in the history
…t to an empty string
  • Loading branch information
matheusmdx committed Oct 31, 2024
1 parent ef8d981 commit 8dcc11a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions scene/animation/animation_mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,12 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
Variant value = a->track_get_key_value(i, idx);
value = post_process_key_value(a, i, value, t->object_id);
Object *t_obj = ObjectDB::get_instance(t->object_id);
// Ignore if is an animation key that set AnimationPlayer.current_animation to an empty string
// otherwise this will start an infinite recursion (see GH-98076).
AnimationPlayer *anim_player = Object::cast_to<AnimationPlayer>(t_obj);
if (anim_player && t->subpath.has("current_animation") && String(value).is_empty()) {
continue;
}
if (t_obj) {
t_obj->set_indexed(t->subpath, value);
}
Expand All @@ -1549,6 +1555,12 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
Variant value = a->track_get_key_value(i, F);
value = post_process_key_value(a, i, value, t->object_id);
Object *t_obj = ObjectDB::get_instance(t->object_id);
// Ignore if is an animation key that set AnimationPlayer.current_animation to an empty string
// otherwise this will start an infinite recursion (see GH-98076).
AnimationPlayer *anim_player = Object::cast_to<AnimationPlayer>(t_obj);
if (anim_player && t->subpath.has("current_animation") && String(value).is_empty()) {
continue;
}
if (t_obj) {
t_obj->set_indexed(t->subpath, value);
}
Expand Down Expand Up @@ -1860,6 +1872,12 @@ void AnimationMixer::_blend_apply() {
}

Object *t_obj = ObjectDB::get_instance(t->object_id);
// Ignore if is an animation key that set AnimationPlayer.current_animation to an empty string
// otherwise this will start an infinite recursion (see GH-98076).
AnimationPlayer *anim_player = Object::cast_to<AnimationPlayer>(t_obj);
if (anim_player && t->subpath.has("current_animation") && t->value.is_null()) {
continue;
}
if (t_obj) {
t_obj->set_indexed(t->subpath, Animation::cast_from_blendwise(t->value, t->init_value.get_type()));
}
Expand Down

0 comments on commit 8dcc11a

Please sign in to comment.