Cleanup actions should not activate tools. It causes all manner of side-effects.
Fixes https://gitlab.com/kicad/code/kicad/issues/13331
This commit is contained in:
parent
589ec27a02
commit
8dc7baad3d
|
@ -1670,7 +1670,7 @@ void SCH_EDIT_FRAME::FixupJunctions()
|
|||
for( auto item : screen->Items() )
|
||||
allItems.Add( item );
|
||||
|
||||
m_toolManager->RunAction( EE_ACTIONS::addNeededJunctions, true, &allItems );
|
||||
m_toolManager->GetTool<SCH_LINE_WIRE_BUS_TOOL>()->AddJunctionsIfNeeded( &allItems );
|
||||
|
||||
// Check if we modified anything during this routine
|
||||
// Needs to happen for every sheet to set the proper modified flag
|
||||
|
|
|
@ -807,17 +807,6 @@ TOOL_ACTION EE_ACTIONS::showHierarchy( "eeschema.EditorTool.showHierarchy",
|
|||
|
||||
// SCH_LINE_WIRE_BUS_TOOL
|
||||
//
|
||||
TOOL_ACTION EE_ACTIONS::addNeededJunctions( "eeschema.InteractiveDrawingLineWireBus.addNeededJunctions",
|
||||
AS_ACTIVE, 0, "",
|
||||
_( "Add Junctions to Selection where needed" ), "",
|
||||
BITMAPS::INVALID_BITMAP, AF_ACTIVATE );
|
||||
|
||||
TOOL_ACTION EE_ACTIONS::trimOverlappingWires( "eeschema.InteractiveDrawingLineWireBus.trimOverlappingWires",
|
||||
AS_ACTIVE, 0, "",
|
||||
"", "",
|
||||
BITMAPS::INVALID_BITMAP, AF_ACTIVATE );
|
||||
|
||||
|
||||
const DRAW_SEGMENT_EVENT_PARAMS drawWireActionParam = { LAYER_WIRE, false, nullptr };
|
||||
TOOL_ACTION EE_ACTIONS::drawWire( "eeschema.InteractiveDrawingLineWireBus.drawWires",
|
||||
AS_GLOBAL,
|
||||
|
|
|
@ -75,8 +75,6 @@ public:
|
|||
static TOOL_ACTION unlock;
|
||||
|
||||
// Schematic Tools
|
||||
static TOOL_ACTION addNeededJunctions;
|
||||
static TOOL_ACTION trimOverlappingWires;
|
||||
static TOOL_ACTION pickerTool;
|
||||
static TOOL_ACTION placeSymbol;
|
||||
static TOOL_ACTION placePower;
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <memory>
|
||||
|
||||
#include <tools/sch_drawing_tools.h>
|
||||
#include <tools/sch_line_wire_bus_tool.h>
|
||||
#include <tools/ee_selection_tool.h>
|
||||
#include <tools/ee_grid_helper.h>
|
||||
#include <ee_actions.h>
|
||||
|
@ -347,10 +348,9 @@ int SCH_DRAWING_TOOLS::PlaceSymbol( const TOOL_EVENT& aEvent )
|
|||
m_view->Update( symbol );
|
||||
m_frame->GetScreen()->Update( symbol );
|
||||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::trimOverlappingWires, true,
|
||||
&m_selectionTool->GetSelection() );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true,
|
||||
&m_selectionTool->GetSelection() );
|
||||
SCH_LINE_WIRE_BUS_TOOL* lwbTool = m_toolMgr->GetTool<SCH_LINE_WIRE_BUS_TOOL>();
|
||||
lwbTool->TrimOverLappingWires( &m_selectionTool->GetSelection() );
|
||||
lwbTool->AddJunctionsIfNeeded( &m_selectionTool->GetSelection() );
|
||||
|
||||
m_frame->OnModify();
|
||||
|
||||
|
@ -1275,6 +1275,7 @@ int SCH_DRAWING_TOOLS::TwoClickPlace( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else if( evt->IsMoveTool() )
|
||||
{
|
||||
// leave ourselves on the stack so we come back after the move
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -761,8 +761,9 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
|
|||
if( selection.IsHover() )
|
||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::trimOverlappingWires, true, &selectionCopy );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selectionCopy );
|
||||
SCH_LINE_WIRE_BUS_TOOL* lwbTool = m_toolMgr->GetTool<SCH_LINE_WIRE_BUS_TOOL>();
|
||||
lwbTool->TrimOverLappingWires( &selectionCopy );
|
||||
lwbTool->AddJunctionsIfNeeded( &selectionCopy );
|
||||
|
||||
m_frame->RecalculateConnections( LOCAL_CLEANUP );
|
||||
m_frame->TestDanglingEnds();
|
||||
|
@ -1131,8 +1132,9 @@ int SCH_EDIT_TOOL::RepeatDrawItem( const TOOL_EVENT& aEvent )
|
|||
|
||||
if( !newItems.Empty() )
|
||||
{
|
||||
m_toolMgr->RunAction( EE_ACTIONS::trimOverlappingWires, true, &newItems );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &newItems );
|
||||
SCH_LINE_WIRE_BUS_TOOL* lwbTool = m_toolMgr->GetTool<SCH_LINE_WIRE_BUS_TOOL>();
|
||||
lwbTool->TrimOverLappingWires( &newItems );
|
||||
lwbTool->AddJunctionsIfNeeded( &newItems );
|
||||
|
||||
m_frame->RecalculateConnections( LOCAL_CLEANUP );
|
||||
m_frame->TestDanglingEnds();
|
||||
|
|
|
@ -1240,9 +1240,8 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments()
|
|||
}
|
||||
|
||||
|
||||
int SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires( const TOOL_EVENT& aEvent )
|
||||
int SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires( EE_SELECTION* aSelection )
|
||||
{
|
||||
EE_SELECTION* aSelection = aEvent.Parameter<EE_SELECTION*>();
|
||||
SCHEMATIC* sch = getModel<SCHEMATIC>();
|
||||
SCH_SCREEN* screen = sch->CurrentSheet().LastScreen();
|
||||
|
||||
|
@ -1285,10 +1284,8 @@ int SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
|
||||
|
||||
int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded( const TOOL_EVENT& aEvent )
|
||||
int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded( EE_SELECTION* aSelection )
|
||||
{
|
||||
EE_SELECTION* aSelection = aEvent.Parameter<EE_SELECTION*>();
|
||||
|
||||
std::vector<VECTOR2I> pts;
|
||||
std::vector<VECTOR2I> connections = m_frame->GetSchematicConnections();
|
||||
|
||||
|
@ -1343,8 +1340,6 @@ int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded( const TOOL_EVENT& aEvent )
|
|||
|
||||
void SCH_LINE_WIRE_BUS_TOOL::setTransitions()
|
||||
{
|
||||
Go( &SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded, EE_ACTIONS::addNeededJunctions.MakeEvent() );
|
||||
Go( &SCH_LINE_WIRE_BUS_TOOL::TrimOverLappingWires, EE_ACTIONS::trimOverlappingWires.MakeEvent() );
|
||||
Go( &SCH_LINE_WIRE_BUS_TOOL::DrawSegments, EE_ACTIONS::drawWire.MakeEvent() );
|
||||
Go( &SCH_LINE_WIRE_BUS_TOOL::DrawSegments, EE_ACTIONS::drawBus.MakeEvent() );
|
||||
Go( &SCH_LINE_WIRE_BUS_TOOL::DrawSegments, EE_ACTIONS::drawLines.MakeEvent() );
|
||||
|
|
|
@ -92,12 +92,12 @@ public:
|
|||
/**
|
||||
* Handle the addition of junctions to a selection of objects
|
||||
*/
|
||||
int AddJunctionsIfNeeded( const TOOL_EVENT& aEvent );
|
||||
int AddJunctionsIfNeeded( EE_SELECTION* aSelection );
|
||||
|
||||
/**
|
||||
* Logic to remove wires when overlapping correct items
|
||||
*/
|
||||
int TrimOverLappingWires( const TOOL_EVENT& aEvent );
|
||||
int TrimOverLappingWires( EE_SELECTION* aSelection );
|
||||
|
||||
private:
|
||||
int doDrawSegments( const TOOL_EVENT& aTool, int aType, bool aQuitOnDraw );
|
||||
|
|
|
@ -915,8 +915,9 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
m_frame->AddJunction( m_frame->GetScreen(), it.GetPosition(), true, false );
|
||||
}
|
||||
|
||||
m_toolMgr->RunAction( EE_ACTIONS::trimOverlappingWires, true, &selectionCopy );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selectionCopy );
|
||||
SCH_LINE_WIRE_BUS_TOOL* lwbTool = m_toolMgr->GetTool<SCH_LINE_WIRE_BUS_TOOL>();
|
||||
lwbTool->TrimOverLappingWires( &selectionCopy );
|
||||
lwbTool->AddJunctionsIfNeeded( &selectionCopy );
|
||||
|
||||
// This needs to run prior to `RecalculateConnections` because we need to identify
|
||||
// the lines that are newly dangling
|
||||
|
@ -1707,9 +1708,11 @@ int SCH_MOVE_TOOL::AlignElements( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
}
|
||||
|
||||
SCH_LINE_WIRE_BUS_TOOL* lwbTool = m_toolMgr->GetTool<SCH_LINE_WIRE_BUS_TOOL>();
|
||||
lwbTool->TrimOverLappingWires( &selection );
|
||||
lwbTool->AddJunctionsIfNeeded( &selection );
|
||||
|
||||
m_toolMgr->PostEvent( EVENTS::SelectedItemsMoved );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::trimOverlappingWires, true, &selection );
|
||||
m_toolMgr->RunAction( EE_ACTIONS::addNeededJunctions, true, &selection );
|
||||
|
||||
m_frame->RecalculateConnections( LOCAL_CLEANUP );
|
||||
m_frame->TestDanglingEnds();
|
||||
|
|
Loading…
Reference in New Issue