Browse Source

Fix potential crash in AnimationPlayer.

Relintai 5 years ago
parent
commit
c39490cf79
1 changed files with 2 additions and 0 deletions
  1. 2 0
      editor/plugins/animation_player_editor_plugin.cpp

+ 2 - 0
editor/plugins/animation_player_editor_plugin.cpp

@@ -484,6 +484,8 @@ double AnimationPlayerEditor::_get_editor_step() const {
 	if (track_editor->is_snap_enabled()) {
 	if (track_editor->is_snap_enabled()) {
 		const String current = player->get_assigned_animation();
 		const String current = player->get_assigned_animation();
 		const Ref<Animation> anim = player->get_animation(current);
 		const Ref<Animation> anim = player->get_animation(current);
+		ERR_FAIL_COND_V(!anim.is_valid(), 0.0);
+
 		// Use more precise snapping when holding Shift
 		// Use more precise snapping when holding Shift
 		return Input::get_singleton()->is_key_pressed(KEY_SHIFT) ? anim->get_step() * 0.25 : anim->get_step();
 		return Input::get_singleton()->is_key_pressed(KEY_SHIFT) ? anim->get_step() * 0.25 : anim->get_step();
 	}
 	}