### 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 (p_idx < 0) {
		p_idx += get_item_count();
	}
	ERR_FAIL_INDEX(p_idx, items.size());
	if (items[p_idx].id == p_id) {
		return;
	}
	items.write[p_idx].id = p_id;
	control->queue_redraw();
	child_controls_changed();
	_menu_changed();
}
void PopupMenu::set_item_accelerator(int p_idx, Key p_accel) {
	if (p_idx < 0) {
		p_idx += get_item_count();
	}
	ERR_FAIL_INDEX(p_idx, items.size());
	if (items[p_idx].accel == p_accel) {
		return;
	}
	items.write[p_idx].accel = p_accel;
	items.write[p_idx].dirty = true;
	control->queue_redraw();
	child_controls_changed();
	_menu_changed();
}
void PopupMenu::set_item_metadata(int p_idx, const Variant &p_meta) {