diff --git a/common/tool/action_menu.cpp b/common/tool/action_menu.cpp index a051d45bd7..7464b036ff 100644 --- a/common/tool/action_menu.cpp +++ b/common/tool/action_menu.cpp @@ -39,7 +39,7 @@ using namespace std::placeholders; ACTION_MENU::ACTION_MENU() : - m_Dirty( true ), + m_dirty( true ), m_titleDisplayed( false ), m_selected( -1 ), m_tool( nullptr ), @@ -244,6 +244,20 @@ void ACTION_MENU::UpdateAll() } +void ACTION_MENU::ClearDirty() +{ + m_dirty = false; + runOnSubmenus( std::bind( &ACTION_MENU::ClearDirty, _1 ) ); +} + + +void ACTION_MENU::SetDirty() +{ + m_dirty = true; + runOnSubmenus( std::bind( &ACTION_MENU::SetDirty, _1 ) ); +} + + void ACTION_MENU::SetTool( TOOL_INTERACTIVE* aTool ) { m_tool = aTool; @@ -319,7 +333,7 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent ) wxEventType type = aEvent.GetEventType(); - if( type == wxEVT_MENU_OPEN && m_Dirty ) + if( type == wxEVT_MENU_OPEN && m_dirty ) { if( m_tool ) getToolManager()->RunAction( ACTIONS::updateMenu, true, this ); diff --git a/common/tool/tool_menu.cpp b/common/tool/tool_menu.cpp index 09d5d2a96e..22433d8f66 100644 --- a/common/tool/tool_menu.cpp +++ b/common/tool/tool_menu.cpp @@ -60,14 +60,14 @@ void TOOL_MENU::ShowContextMenu( SELECTION& aSelection ) { m_menu.Evaluate( aSelection ); m_menu.UpdateAll(); - m_menu.m_Dirty = false; + m_menu.ClearDirty(); m_tool.SetContextMenu( &m_menu, CMENU_NOW ); } void TOOL_MENU::ShowContextMenu() { - m_menu.m_Dirty = true; + m_menu.SetDirty(); m_tool.SetContextMenu( &m_menu, CMENU_NOW ); } diff --git a/eeschema/tools/sch_wire_bus_tool.cpp b/eeschema/tools/sch_wire_bus_tool.cpp index 5ce496b988..b07db51952 100644 --- a/eeschema/tools/sch_wire_bus_tool.cpp +++ b/eeschema/tools/sch_wire_bus_tool.cpp @@ -126,6 +126,8 @@ private: SELECTION& selection = selTool->RequestSelection( busType ); SCH_LINE* bus = (SCH_LINE*) selection.Front(); + Clear(); + // TODO(JE) remove once real-time is enabled if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime ) { @@ -166,7 +168,7 @@ private: if( member->Type() == CONNECTION_BUS ) { - wxMenu* submenu = new ACTION_MENU; + ACTION_MENU* submenu = new ACTION_MENU; AppendSubMenu( submenu, name ); for( const auto& sub_member : member->Members() ) diff --git a/include/tool/action_menu.h b/include/tool/action_menu.h index 82ac272ce6..8f53378a16 100644 --- a/include/tool/action_menu.h +++ b/include/tool/action_menu.h @@ -128,6 +128,13 @@ public: */ void UpdateAll(); + /** + * Function ClearDirty() + * Clears the dirty flag on the menu and all descendants. + */ + void ClearDirty(); + void SetDirty(); + /** * Function SetTool() * Sets a tool that is the creator of the menu. @@ -140,10 +147,6 @@ public: */ ACTION_MENU* Clone() const; -public: - ///> Menu requires updating before display. - bool m_Dirty; - ///> The default menu event handler. void OnMenuEvent( wxMenuEvent& aEvent ); @@ -206,6 +209,9 @@ protected: ///> Checks if any of submenus contains a TOOL_ACTION with a specific ID. OPT_TOOL_EVENT findToolAction( int aId ); + ///> Menu requires updating before display. + bool m_dirty; + ///> Flag indicating that the menu title was set up. bool m_titleDisplayed;