### 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?)
if (!animation->track_is_compressed(track)) { 
			float scale = timeline->get_zoom_scale();
			int limit = timeline->get_name_limit();
			int limit_end = get_size().width - timeline->get_buttons_width();
			
			int limit_start_hitbox = limit - type_icon->get_width();
			if (pos.x >= limit_start_hitbox && pos.x <= limit_end) {
				int key_idx = -1;
				float key_distance = 1e20;
				
				for (int i = animation->track_get_key_count(track) - 1; i >= 0; i--) {
					Rect2 rect = get_key_rect(i, scale);
					float offset = animation->track_get_key_time(track, i) - timeline->get_value();
					offset = offset * scale + limit;
					rect.position.x += offset;
					if (rect.has_point(pos)) {
						if (is_key_selectable_by_distance()) {
							float distance = ABS(offset - pos.x);
							if (key_idx == -1 || distance < key_distance) {
								key_idx = i;
								key_distance = distance;
							}
						} else {
							
							key_idx = i;
							break;
						}
					}
				}
				if (key_idx != -1) {