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
This commit is contained in:
Jeff Young 2019-07-19 14:47:33 -06:00
parent fcff0dd228
commit 0b08e4dcd2
6 changed files with 33 additions and 0 deletions

View File

@ -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(

View File

@ -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(

View File

@ -438,6 +438,9 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent )
{
PICKER_TOOL* picker = m_toolMgr->GetTool<PICKER_TOOL>();
// 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<PICKER_TOOL>();
// 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<PICKER_TOOL>();
// Deactivate other tools; particularly important if another PICKER is currently running
Activate();
picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
picker->SetClickHandler(

View File

@ -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<PICKER_TOOL>();
// Deactivate other tools; particularly important if another PICKER is currently running
Activate();
picker->SetCursor( wxStockCursor( wxCURSOR_BULLSEYE ) );
m_pickerItem = nullptr;

View File

@ -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<PCBNEW_PICKER_TOOL>();
// 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<PCBNEW_PICKER_TOOL>();
// 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<BOARD>();
PCB_DISPLAY_OPTIONS* opt = displayOptions();
// Deactivate other tools; particularly important if another PICKER is currently running
Activate();
picker->SetClickHandler(
[&] ( const VECTOR2D& pt ) -> bool
{

View File

@ -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<PCBNEW_PICKER_TOOL>();
// 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(