### 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
return;
	}
	submenu_pum->activated_by_keyboard = p_by_keyboard;
	
	if (p_by_keyboard) {
		for (int i = 0; i < submenu_pum->get_item_count(); i++) {
			if (!submenu_pum->is_item_disabled(i)) {
				submenu_pum->set_focused_item(i);
				break;
			}
		}
	}
	submenu_pum->popup();
	
	Rect2 safe_area = this_rect;
	safe_area.position.y += items[p_over]._ofs_cache + scroll_offset + theme_cache.panel_style->get_offset().height - theme_cache.v_separation / 2;
	safe_area.size.y = items[p_over]._height_cache + theme_cache.v_separation;
	DisplayServer::get_singleton()->window_set_popup_safe_rect(submenu_popup->get_window_id(), safe_area);
	
	this_rect.position = this_rect.position - submenu_pum->get_position();
	
	submenu_pum->clear_autohide_areas();
	submenu_pum->add_autohide_area(Rect2(this_rect.position.x, this_rect.position.y, this_rect.size.x, items[p_over]._ofs_cache + scroll_offset + theme_cache.panel_style->get_offset().height - theme_cache.v_separation / 2));
	
	if (items[p_over]._ofs_cache + items[p_over]._height_cache + scroll_offset <= control->get_size().height) {
		int from = items[p_over]._ofs_cache + items[p_over]._height_cache + scroll_offset + theme_cache.v_separation / 2 + theme_cache.panel_style->get_offset().height;
		submenu_pum->add_autohide_area(Rect2(this_rect.position.x, this_rect.position.y + from, this_rect.size.x, this_rect.size.y - from));
	}
}
void PopupMenu::_parent_focused() {