Don't create 0-length tracks when placing via in the middle of a track.

(cherry picked from commit 8fe78101db)
This commit is contained in:
Alex 2023-03-16 03:15:55 +03:00 committed by dsa-t
parent 25f40566ed
commit 1c06f4cf06
1 changed files with 22 additions and 16 deletions

View File

@ -3089,26 +3089,32 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
track->SetStart( trackStart );
track->SetEnd( *joint1 );
if( *joint1 != viaPos )
{
PCB_TRACK* newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
wxCHECK( newTrack, /* void */ );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( *joint1 );
newTrack->SetEnd( viaPos );
aCommit.Add( newTrack );
}
if( *joint2 != viaPos )
{
PCB_TRACK* newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
wxCHECK( newTrack, /* void */ );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( viaPos );
newTrack->SetEnd( *joint2 );
aCommit.Add( newTrack );
}
PCB_TRACK* newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
wxCHECK( newTrack, /* void */ );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( *joint1 );
newTrack->SetEnd( viaPos );
aCommit.Add( newTrack );
newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
wxCHECK( newTrack, /* void */ );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( viaPos );
newTrack->SetEnd( *joint2 );
aCommit.Add( newTrack );
newTrack = dynamic_cast<PCB_TRACK*>( track->Clone() );
wxCHECK( newTrack, /* void */ );
const_cast<KIID&>( newTrack->m_Uuid ) = KIID();
newTrack->SetStart( *joint2 );
newTrack->SetEnd( trackEnd );
aCommit.Add( newTrack );