From 05429bc39c8091c43c23e8ba2aba512521eaff03 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Fri, 2 Aug 2019 10:40:19 +0200 Subject: [PATCH] Recursively call evaluate on submenus of conditional menus There seems to be a bug with certain GTK setups that prevents the submenus from getting sized correctly unless the elements are added when the main menu is displayed. Fixes: lp:1835460 * https://bugs.launchpad.net/kicad/+bug/1835460 --- common/tool/conditional_menu.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp index c3a8b5f097..6f968d6817 100644 --- a/common/tool/conditional_menu.cpp +++ b/common/tool/conditional_menu.cpp @@ -197,6 +197,18 @@ void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection ) menuItem->Enable( result ); } } + + // Recursively call Evaluate on all the submenus that are CONDITIONAL_MENUs to ensure + // they are updated. This is also required on GTK to make sure the menus have the proper + // size when created. + runOnSubmenus( + [&aSelection]( ACTION_MENU* aMenu ) + { + CONDITIONAL_MENU* conditionalMenu = dynamic_cast( aMenu ); + + if( conditionalMenu ) + conditionalMenu->Evaluate( aSelection ); + } ); }