### Godot version

4.0.dev (c309de53997feff3286295fb2d71657f112a15db)

### System information

Linux, Nvidia, Vulkan

### Issue description

Editor segfaults when certain conditions are met when using the AnimationPlayer editor.

### Steps to reproduce

1. Create multiple animations, saved into a animation collection
2. Open an existing animation, then make a new empty animation
3. Change from seconds to fps, or add a new property to animate ()
4. Editor crashes

NOTE: It is slightly random and I have not found a perfect repro

### Minimal reproduction project

N/A (TBD?)
undo_redo->commit_action();
		} break;
		case Animation::TYPE_ROTATION_3D: {
			if (!root->has_node(animation->track_get_path(p_track))) {
				EditorNode::get_singleton()->show_warning(TTR("Track path is invalid, so can't add a key."));
				return;
			}
			Node3D *base = Object::cast_to<Node3D>(root->get_node(animation->track_get_path(p_track)));
			if (!base) {
				EditorNode::get_singleton()->show_warning(TTR("Track is not of type Node3D, can't insert key"));
				return;
			}
			Quaternion rot = base->get_transform().basis.operator Quaternion();
			undo_redo->create_action(TTR("Add Rotation Key"));
			undo_redo->add_do_method(animation.ptr(), "rotation_track_insert_key", p_track, p_ofs, rot);
			undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs);
			undo_redo->commit_action();
		} break;
		case Animation::TYPE_SCALE_3D: {
			if (!root->has_node(animation->track_get_path(p_track))) {
				EditorNode::get_singleton()->show_warning(TTR("Track path is invalid, so can't add a key."));
				return;
			}
			Node3D *base = Object::cast_to<Node3D>(root->get_node(animation->track_get_path(p_track)));
			if (!base) {
				EditorNode::get_singleton()->show_warning(TTR("Track is not of type Node3D, can't insert key"));
				return;
			}
			undo_redo->create_action(TTR("Add Scale Key"));
			undo_redo->add_do_method(animation.ptr(), "scale_track_insert_key", p_track, p_ofs, base->get_scale());