diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-09 15:31:21 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-10-09 15:31:21 +0200 |
| commit | c4effea5e6fefc0194f52247a21d9fc5d916b2c3 (patch) | |
| tree | 65f9e02a5cd54d707946a27686775d6993d61d6f | |
| parent | c1fed539435b61fe5d6b05bee96d3280e746eebe (diff) | |
| parent | e7a35d152104c14ba89861a6ead892c4f65d9f5d (diff) | |
| download | redot-engine-c4effea5e6fefc0194f52247a21d9fc5d916b2c3.tar.gz | |
Merge pull request #81779 from RealMadvicius/fix/4.2/81769_animationplayer_crash
Fix crash when clicking on "Interpolation Mode" with nonexistent node path
| -rw-r--r-- | editor/animation_track_editor.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 919e335d21..8f2b50ebd0 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -2695,18 +2695,25 @@ void AnimationTrackEdit::gui_input(const Ref<InputEvent> &p_event) { AnimationPlayer *ap = ape->get_player(); if (ap) { NodePath npath = animation->track_get_path(track); - Node *nd = ap->get_node(ap->get_root_node())->get_node(NodePath(npath.get_concatenated_names())); - StringName prop = npath.get_concatenated_subnames(); - PropertyInfo prop_info; - ClassDB::get_property_info(nd->get_class(), prop, &prop_info); + Node *a_ap_root_node = ap->get_node(ap->get_root_node()); + Node *nd = nullptr; + // We must test that we have a valid a_ap_root_node before trying to access its content to init the nd Node. + 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 - 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 - 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 - 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("InterpCubicAngle")), TTR("Cubic Angle"), MENU_INTERPOLATION_CUBIC_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("InterpCubicAngle")), TTR("Cubic Angle"), MENU_INTERPOLATION_CUBIC_ANGLE); + } } } } |
