From 0b08e4dcd2c01aecc5b95e8f2e19574e040e98d0 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 19 Jul 2019 14:47:33 -0600 Subject: [PATCH] Deactivate other tools when running one based on a PICKER. In particular, if the last one was a PICKER tool, then we're going to assert on "click-handler-already-set". Fixes: lp:1836673 * https://bugs.launchpad.net/kicad/+bug/1836673 --- eeschema/tools/lib_edit_tool.cpp | 3 +++ eeschema/tools/sch_edit_tool.cpp | 3 +++ eeschema/tools/sch_editor_control.cpp | 9 +++++++++ pagelayout_editor/tools/pl_edit_tool.cpp | 3 +++ pcbnew/tools/pcb_editor_control.cpp | 9 +++++++++ pcbnew/tools/pcbnew_control.cpp | 6 ++++++ 6 files changed, 33 insertions(+) diff --git a/eeschema/tools/lib_edit_tool.cpp b/eeschema/tools/lib_edit_tool.cpp index 8ee95c2581..eb84aec51d 100644 --- a/eeschema/tools/lib_edit_tool.cpp +++ b/eeschema/tools/lib_edit_tool.cpp @@ -286,6 +286,9 @@ int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_pickerItem = nullptr; + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) ); picker->SetClickHandler( diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 025222caf2..95c0d15d79 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -946,6 +946,9 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); m_pickerItem = nullptr; + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) ); picker->SetClickHandler( diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index a2dc582bb4..a94e0a171a 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -438,6 +438,9 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) { PICKER_TOOL* picker = m_toolMgr->GetTool(); + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::PROBE ) ); picker->SetClickHandler( @@ -481,6 +484,9 @@ int SCH_EDITOR_CONTROL::SimTune( const TOOL_EVENT& aEvent ) { PICKER_TOOL* picker = m_toolMgr->GetTool(); + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetCursor( SIMULATION_CURSORS::GetCursor( SIMULATION_CURSORS::CURSOR::TUNE ) ); picker->SetClickHandler( @@ -672,6 +678,9 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent ) std::string tool = aEvent.GetCommandStr().get(); PICKER_TOOL* picker = m_toolMgr->GetTool(); + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) ); picker->SetClickHandler( diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index 7fb5f82918..44d478adba 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -341,6 +341,9 @@ int PL_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent ) std::string tool = aEvent.GetCommandStr().get(); PICKER_TOOL* picker = m_toolMgr->GetTool(); + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) ); m_pickerItem = nullptr; diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index 853e822570..dbf0680bfb 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -1130,6 +1130,9 @@ int PCB_EDITOR_CONTROL::DrillOrigin( const TOOL_EVENT& aEvent ) std::string tool = aEvent.GetCommandStr().get(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool(); + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool { @@ -1304,6 +1307,9 @@ int PCB_EDITOR_CONTROL::HighlightNetTool( const TOOL_EVENT& aEvent ) std::string tool = aEvent.GetCommandStr().get(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool(); + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + // If the keyboard hotkey was triggered and we are already in the highlight tool, behave // the same as a left-click. Otherwise highlight the net of the selected item(s), or if // there is no selection, then behave like a ctrl-left-click. @@ -1335,6 +1341,9 @@ int PCB_EDITOR_CONTROL::LocalRatsnestTool( const TOOL_EVENT& aEvent ) BOARD* board = getModel(); PCB_DISPLAY_OPTIONS* opt = displayOptions(); + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetClickHandler( [&] ( const VECTOR2D& pt ) -> bool { diff --git a/pcbnew/tools/pcbnew_control.cpp b/pcbnew/tools/pcbnew_control.cpp index 1c864d033b..bbc03acee0 100644 --- a/pcbnew/tools/pcbnew_control.cpp +++ b/pcbnew/tools/pcbnew_control.cpp @@ -450,6 +450,9 @@ int PCBNEW_CONTROL::GridSetOrigin( const TOOL_EVENT& aEvent ) std::string tool = aEvent.GetCommandStr().get(); PCBNEW_PICKER_TOOL* picker = m_toolMgr->GetTool(); + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetClickHandler( [this] ( const VECTOR2D& pt ) -> bool { @@ -484,6 +487,9 @@ int PCBNEW_CONTROL::DeleteItemCursor( const TOOL_EVENT& aEvent ) m_pickerItem = nullptr; m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + // Deactivate other tools; particularly important if another PICKER is currently running + Activate(); + picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) ); picker->SetClickHandler(