1
0
Fork 0

Merge pull request #81779 from RealMadvicius/fix/4.2/81769_animationplayer_crash

Fix crash when clicking on "Interpolation Mode" with nonexistent node path
This commit is contained in:
Rémi Verschelde 2023-10-09 15:31:21 +02:00
commit c4effea5e6
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 16 additions and 9 deletions

View File

@ -2695,18 +2695,25 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) {
AnimationPlayer *ap = ape->get_player(); AnimationPlayer *ap = ape->get_player();
if (ap) { if (ap) {
NodePath npath = animation->track_get_path(track); NodePath npath = animation->track_get_path(track);
Node *nd = ap->get_node(ap->get_root_node())->get_node(NodePath(npath.get_concatenated_names())); Node *a_ap_root_node = ap->get_node(ap->get_root_node());
StringName prop = npath.get_concatenated_subnames(); Node *nd = nullptr;
PropertyInfo prop_info; // We must test that we have a valid a_ap_root_node before trying to access its content to init the nd Node.
ClassDB::get_property_info(nd->get_class(), prop, &prop_info); if (a_ap_root_node) {
nd = a_ap_root_node->get_node(NodePath(npath.get_concatenated_names()));
}
if (nd) {
StringName prop = npath.get_concatenated_subnames();
PropertyInfo prop_info;
ClassDB::get_property_info(nd->get_class(), prop, &prop_info);
#ifdef DISABLE_DEPRECATED #ifdef DISABLE_DEPRECATED
bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians_as_degrees") != -1; bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians_as_degrees") != -1;
#else #else
bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians") != -1; bool is_angle = prop_info.type == Variant::FLOAT && prop_info.hint_string.find("radians") != -1;
#endif // DISABLE_DEPRECATED #endif // DISABLE_DEPRECATED
if (is_angle) { if (is_angle) {
menu->add_icon_item(get_editor_theme_icon(SNAME("InterpLinearAngle")), TTR("Linear Angle"), MENU_INTERPOLATION_LINEAR_ANGLE); menu->add_icon_item(get_editor_theme_icon(SNAME("InterpLinearAngle")), TTR("Linear Angle"), MENU_INTERPOLATION_LINEAR_ANGLE);
menu->add_icon_item(get_editor_theme_icon(SNAME("InterpCubicAngle")), TTR("Cubic Angle"), MENU_INTERPOLATION_CUBIC_ANGLE); menu->add_icon_item(get_editor_theme_icon(SNAME("InterpCubicAngle")), TTR("Cubic Angle"), MENU_INTERPOLATION_CUBIC_ANGLE);
}
} }
} }
} }