### 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->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs);
			undo_redo->commit_action();
		} break;
		case Animation::TYPE_BLEND_SHAPE:
		case Animation::TYPE_VALUE: {
			NodePath bp;
			Variant value;
			_find_hint_for_track(p_track, bp, &value);
			undo_redo->create_action(TTR("Add Track Key"));
			undo_redo->add_do_method(animation.ptr(), "track_insert_key", p_track, p_ofs, value);
			undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation);
			undo_redo->add_undo_method(animation.ptr(), "track_remove_key_at_time", p_track, p_ofs);
			undo_redo->commit_action();
		} break;
		case Animation::TYPE_METHOD: {
			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 method key."));
				return;
			}
			Node *base = root->get_node(animation->track_get_path(p_track));
			method_selector->select_method_from_instance(base);
			insert_key_from_track_call_ofs = p_ofs;
			insert_key_from_track_call_track = p_track;
		} break;
		case Animation::TYPE_BEZIER: {
			NodePath bp;
			Variant value;
			_find_hint_for_track(p_track, bp, &value);
			Array arr;
			arr.resize(5);