Mark unfold bus menu as clean so it doesn't get generated a second time.

Fixes: lp:1829878
* https://bugs.launchpad.net/kicad/+bug/1829878
This commit is contained in:
Jeff Young 2019-05-22 22:11:05 +01:00
parent 1636405b66
commit 0047f88f82
4 changed files with 31 additions and 9 deletions

View File

@ -39,7 +39,7 @@ using namespace std::placeholders;
ACTION_MENU::ACTION_MENU() : ACTION_MENU::ACTION_MENU() :
m_Dirty( true ), m_dirty( true ),
m_titleDisplayed( false ), m_titleDisplayed( false ),
m_selected( -1 ), m_selected( -1 ),
m_tool( nullptr ), 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 ) void ACTION_MENU::SetTool( TOOL_INTERACTIVE* aTool )
{ {
m_tool = aTool; m_tool = aTool;
@ -319,7 +333,7 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent )
wxEventType type = aEvent.GetEventType(); wxEventType type = aEvent.GetEventType();
if( type == wxEVT_MENU_OPEN && m_Dirty ) if( type == wxEVT_MENU_OPEN && m_dirty )
{ {
if( m_tool ) if( m_tool )
getToolManager()->RunAction( ACTIONS::updateMenu, true, this ); getToolManager()->RunAction( ACTIONS::updateMenu, true, this );

View File

@ -60,14 +60,14 @@ void TOOL_MENU::ShowContextMenu( SELECTION& aSelection )
{ {
m_menu.Evaluate( aSelection ); m_menu.Evaluate( aSelection );
m_menu.UpdateAll(); m_menu.UpdateAll();
m_menu.m_Dirty = false; m_menu.ClearDirty();
m_tool.SetContextMenu( &m_menu, CMENU_NOW ); m_tool.SetContextMenu( &m_menu, CMENU_NOW );
} }
void TOOL_MENU::ShowContextMenu() void TOOL_MENU::ShowContextMenu()
{ {
m_menu.m_Dirty = true; m_menu.SetDirty();
m_tool.SetContextMenu( &m_menu, CMENU_NOW ); m_tool.SetContextMenu( &m_menu, CMENU_NOW );
} }

View File

@ -126,6 +126,8 @@ private:
SELECTION& selection = selTool->RequestSelection( busType ); SELECTION& selection = selTool->RequestSelection( busType );
SCH_LINE* bus = (SCH_LINE*) selection.Front(); SCH_LINE* bus = (SCH_LINE*) selection.Front();
Clear();
// TODO(JE) remove once real-time is enabled // TODO(JE) remove once real-time is enabled
if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime ) if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
{ {
@ -166,7 +168,7 @@ private:
if( member->Type() == CONNECTION_BUS ) if( member->Type() == CONNECTION_BUS )
{ {
wxMenu* submenu = new ACTION_MENU; ACTION_MENU* submenu = new ACTION_MENU;
AppendSubMenu( submenu, name ); AppendSubMenu( submenu, name );
for( const auto& sub_member : member->Members() ) for( const auto& sub_member : member->Members() )

View File

@ -128,6 +128,13 @@ public:
*/ */
void UpdateAll(); void UpdateAll();
/**
* Function ClearDirty()
* Clears the dirty flag on the menu and all descendants.
*/
void ClearDirty();
void SetDirty();
/** /**
* Function SetTool() * Function SetTool()
* Sets a tool that is the creator of the menu. * Sets a tool that is the creator of the menu.
@ -140,10 +147,6 @@ public:
*/ */
ACTION_MENU* Clone() const; ACTION_MENU* Clone() const;
public:
///> Menu requires updating before display.
bool m_Dirty;
///> The default menu event handler. ///> The default menu event handler.
void OnMenuEvent( wxMenuEvent& aEvent ); void OnMenuEvent( wxMenuEvent& aEvent );
@ -206,6 +209,9 @@ protected:
///> Checks if any of submenus contains a TOOL_ACTION with a specific ID. ///> Checks if any of submenus contains a TOOL_ACTION with a specific ID.
OPT_TOOL_EVENT findToolAction( int aId ); OPT_TOOL_EVENT findToolAction( int aId );
///> Menu requires updating before display.
bool m_dirty;
///> Flag indicating that the menu title was set up. ///> Flag indicating that the menu title was set up.
bool m_titleDisplayed; bool m_titleDisplayed;