From b2d47352d0aedcd66920ceba83c3e9d6972cb661 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Mon, 26 May 2025 14:12:38 +0800 Subject: [PATCH] Fix MenuBar min size not updating after child rename --- scene/gui/menu_bar.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scene/gui/menu_bar.cpp b/scene/gui/menu_bar.cpp index b1a8a406369..54a5f3bfd0c 100644 --- a/scene/gui/menu_bar.cpp +++ b/scene/gui/menu_bar.cpp @@ -519,13 +519,14 @@ void MenuBar::_refresh_menu_names() { bool is_global = !global_menu_tag.is_empty(); RID main_menu = is_global ? nmenu->get_system_menu(NativeMenu::MAIN_MENU_ID) : RID(); + bool dirty = false; Vector popups = _get_popups(); for (int i = 0; i < popups.size(); i++) { String menu_name = popups[i]->get_title().is_empty() ? String(popups[i]->get_name()) : popups[i]->get_title(); if (!popups[i]->has_meta("_menu_name") && menu_name != get_menu_title(i)) { menu_cache.write[i].name = menu_name; shape(menu_cache.write[i]); - queue_redraw(); + dirty = true; if (is_global && menu_cache[i].submenu_rid.is_valid()) { int item_idx = nmenu->find_item_index_with_submenu(main_menu, menu_cache[i].submenu_rid); if (item_idx >= 0) { @@ -534,6 +535,11 @@ void MenuBar::_refresh_menu_names() { } } } + + if (dirty && !is_global) { + queue_redraw(); + update_minimum_size(); + } } Vector MenuBar::_get_popups() const {