Don't add second half of line and new juction to screen twice.

Fixes https://gitlab.com/kicad/code/kicad/issues/13129
This commit is contained in:
Jeff Young 2022-12-12 13:44:19 +00:00
parent 45eae3e594
commit 2459b61aa6
1 changed files with 19 additions and 14 deletions

View File

@ -529,6 +529,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
for( EDA_ITEM* item : selection ) for( EDA_ITEM* item : selection )
static_cast<SCH_ITEM*>( item )->UpdateDanglingState( internalPoints ); static_cast<SCH_ITEM*>( item )->UpdateDanglingState( internalPoints );
} }
// Generic setup // Generic setup
// //
for( EDA_ITEM* item : selection ) for( EDA_ITEM* item : selection )
@ -549,19 +550,10 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
} }
if( item->IsNew() ) if( item->IsNew() )
{
if( item->HasFlag( SELECTED_BY_DRAG ) && m_isDrag )
{
// Item was added in getConnectedDragItems
saveCopyInUndoList( (SCH_ITEM*) item, UNDO_REDO::NEWITEM, appendUndo );
appendUndo = true;
}
else
{ {
// Item was added in a previous command (and saved to undo by // Item was added in a previous command (and saved to undo by
// that command) // that command)
} }
}
else if( item->GetParent() && item->GetParent()->IsSelected() ) else if( item->GetParent() && item->GetParent()->IsSelected() )
{ {
// Item will be (or has been) saved to undo by parent // Item will be (or has been) saved to undo by parent
@ -1183,7 +1175,9 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aSelectedItem, const VECTOR
line->SetFlags( STARTPOINT ); line->SetFlags( STARTPOINT );
if( line->HasFlag( SELECTED ) || line->HasFlag( SELECTED_BY_DRAG ) ) if( line->HasFlag( SELECTED ) || line->HasFlag( SELECTED_BY_DRAG ) )
{
continue; continue;
}
else else
{ {
line->SetFlags( SELECTED_BY_DRAG ); line->SetFlags( SELECTED_BY_DRAG );
@ -1195,7 +1189,9 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aSelectedItem, const VECTOR
line->SetFlags( ENDPOINT ); line->SetFlags( ENDPOINT );
if( line->HasFlag( SELECTED ) || line->HasFlag( SELECTED_BY_DRAG ) ) if( line->HasFlag( SELECTED ) || line->HasFlag( SELECTED_BY_DRAG ) )
{
continue; continue;
}
else else
{ {
line->SetFlags( SELECTED_BY_DRAG ); line->SetFlags( SELECTED_BY_DRAG );
@ -1222,6 +1218,9 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aSelectedItem, const VECTOR
newWire->StoreAngle( ( line->Angle() + ANGLE_90 ).Normalize() ); newWire->StoreAngle( ( line->Angle() + ANGLE_90 ).Normalize() );
aList.push_back( newWire ); aList.push_back( newWire );
saveCopyInUndoList( newWire, UNDO_REDO::NEWITEM, aAppendUndo );
aAppendUndo = true;
if( aPoint != line->GetStartPoint() && aPoint != line->GetEndPoint() ) if( aPoint != line->GetStartPoint() && aPoint != line->GetEndPoint() )
{ {
// Split line in half // Split line in half
@ -1245,9 +1244,6 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aSelectedItem, const VECTOR
junction->SetFlags( SELECTED_BY_DRAG ); junction->SetFlags( SELECTED_BY_DRAG );
saveCopyInUndoList( junction, UNDO_REDO::NEWITEM, aAppendUndo ); saveCopyInUndoList( junction, UNDO_REDO::NEWITEM, aAppendUndo );
aAppendUndo = true; aAppendUndo = true;
m_frame->AddToScreen( secondHalf, m_frame->GetScreen() );
m_frame->AddToScreen( junction, m_frame->GetScreen() );
} }
else else
{ {
@ -1308,6 +1304,9 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aSelectedItem, const VECTOR
newWire = makeNewWire( pin, aSelectedItem, aPoint, aPoint ); newWire = makeNewWire( pin, aSelectedItem, aPoint, aPoint );
newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT ); newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
aList.push_back( newWire ); aList.push_back( newWire );
saveCopyInUndoList( newWire, UNDO_REDO::NEWITEM, aAppendUndo );
aAppendUndo = true;
} }
} }
} }
@ -1323,6 +1322,9 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aSelectedItem, const VECTOR
newWire = makeNewWire( test, aSelectedItem, aPoint, aPoint ); newWire = makeNewWire( test, aSelectedItem, aPoint, aPoint );
newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT ); newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
aList.push_back( newWire ); aList.push_back( newWire );
saveCopyInUndoList( newWire, UNDO_REDO::NEWITEM, aAppendUndo );
aAppendUndo = true;
} }
break; break;
@ -1386,6 +1388,9 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aSelectedItem, const VECTOR
newWire = makeNewWire( test, aSelectedItem, aPoint, aPoint ); newWire = makeNewWire( test, aSelectedItem, aPoint, aPoint );
newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT ); newWire->SetFlags( SELECTED_BY_DRAG | STARTPOINT );
aList.push_back( newWire ); aList.push_back( newWire );
saveCopyInUndoList( newWire, UNDO_REDO::NEWITEM, aAppendUndo );
aAppendUndo = true;
} }
break; break;