### 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
const PopupMenu::Item &item = items[p_idx];
	Size2 icon_size = item.get_icon_size();
	int max_width = 0;
	if (theme_cache.icon_max_width > 0) {
		max_width = theme_cache.icon_max_width;
	}
	if (item.icon_max_width > 0 && (max_width == 0 || item.icon_max_width < max_width)) {
		max_width = item.icon_max_width;
	}
	if (max_width > 0 && icon_size.width > max_width) {
		icon_size.height = icon_size.height * max_width / icon_size.width;
		icon_size.width = max_width;
	}
	return icon_size;
}
Size2 PopupMenu::_get_contents_minimum_size() const {
	Size2 minsize = theme_cache.panel_style->get_minimum_size(); 
	minsize.x += scroll_container->get_v_scroll_bar()->get_size().width * 2; 
	float max_w = 0.0;
	float icon_w = 0.0;
	int check_w = MAX(theme_cache.checked->get_width(), theme_cache.radio_checked->get_width()) + theme_cache.h_separation;
	int accel_max_w = 0;
	bool has_check = false;
	for (int i = 0; i < items.size(); i++) {
		Size2 item_size;
		const_cast<PopupMenu *>(this)->_shape_item(i);
		Size2 icon_size = _get_item_icon_size(i);
		item_size.height = _get_item_height(i);
		icon_w = MAX(icon_size.width, icon_w);
		item_size.width += items[i].indent * theme_cache.indent;