### 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
emit_signal(SNAME("menu_changed"));
}
void PopupMenu::add_child_notify(Node *p_child) {
	Window::add_child_notify(p_child);
	PopupMenu *pm = Object::cast_to<PopupMenu>(p_child);
	if (!pm) {
		return;
	}
	p_child->connect("menu_changed", callable_mp(this, &PopupMenu::_menu_changed));
	_menu_changed();
}
void PopupMenu::remove_child_notify(Node *p_child) {
	Window::remove_child_notify(p_child);
	PopupMenu *pm = Object::cast_to<PopupMenu>(p_child);
	if (!pm) {
		return;
	}
	p_child->disconnect("menu_changed", callable_mp(this, &PopupMenu::_menu_changed));
	_menu_changed();
}
void PopupMenu::_update_theme_item_cache() {
	Popup::_update_theme_item_cache();
	theme_cache.panel_style = get_theme_stylebox(SNAME("panel"));
	theme_cache.hover_style = get_theme_stylebox(SNAME("hover"));
	theme_cache.separator_style = get_theme_stylebox(SNAME("separator"));
	theme_cache.labeled_separator_left = get_theme_stylebox(SNAME("labeled_separator_left"));
	theme_cache.labeled_separator_right = get_theme_stylebox(SNAME("labeled_separator_right"));
	theme_cache.v_separation = get_theme_constant(SNAME("v_separation"));