### 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
Item item;
	item.text = p_label;
	item.xl_text = atr(p_label);
	item.id = p_id == -1 ? items.size() : p_id;
	item.submenu = p_submenu;
	items.push_back(item);
	_shape_item(items.size() - 1);
	control->queue_redraw();
	child_controls_changed();
	_menu_changed();
}
#undef ITEM_SETUP_WITH_ACCEL
#undef ITEM_SETUP_WITH_SHORTCUT
void PopupMenu::set_item_text(int p_idx, const String &p_text) {
	if (p_idx < 0) {
		p_idx += get_item_count();
	}
	ERR_FAIL_INDEX(p_idx, items.size());
	if (items[p_idx].text == p_text) {
		return;
	}
	items.write[p_idx].text = p_text;
	items.write[p_idx].xl_text = atr(p_text);
	items.write[p_idx].dirty = true;
	_shape_item(p_idx);
	control->queue_redraw();
	child_controls_changed();
	_menu_changed();
}
void PopupMenu::set_item_text_direction(int p_idx, Control::TextDirection p_text_direction) {