### Godot version

4.0.2

### System information

Windows 11

### Issue description

Changing node type from PopupMenu to ItemList causes Godot to crash

### Steps to reproduce

Change node type from PopupMenu to ItemList

### Minimal reproduction project

n/a
if (items[i].checkable_type && !items[i].separator) {
			has_check = true;
		}
		item_size.width += items[i].text_buf->get_size().x;
		item_size.height += theme_cache.v_separation;
		if (items[i].accel != Key::NONE || (items[i].shortcut.is_valid() && items[i].shortcut->has_valid_event())) {
			int accel_w = theme_cache.h_separation * 2;
			accel_w += items[i].accel_text_buf->get_size().x;
			accel_max_w = MAX(accel_w, accel_max_w);
		}
		if (!items[i].submenu.is_empty()) {
			item_size.width += theme_cache.submenu->get_width();
		}
		max_w = MAX(max_w, item_size.width);
		minsize.height += item_size.height;
	}
	int item_side_padding = theme_cache.item_start_padding + theme_cache.item_end_padding;
	minsize.width += max_w + icon_w + accel_max_w + item_side_padding;
	if (has_check) {
		minsize.width += check_w;
	}
	if (is_inside_tree()) {
		int height_limit = get_usable_parent_rect().size.height;
		if (minsize.height > height_limit) {
			minsize.height = height_limit;
		}
	}
	return minsize;
}
int PopupMenu::_get_item_height(int p_idx) const {