Don't set FreeVia when we can't find a net.

Fixes https://gitlab.com/kicad/code/kicad/issues/12421
This commit is contained in:
Jeff Young 2022-09-15 18:35:26 +01:00
parent 19d8dcad8b
commit ce9adeaf51
1 changed files with 13 additions and 9 deletions

View File

@ -3002,18 +3002,28 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
PAD* pad = findPad( via );
if( track )
{
via->SetNetCode( track->GetNetCode() );
via->SetIsFree( false );
}
else if( pad )
{
via->SetNetCode( pad->GetNetCode() );
via->SetIsFree( false );
}
else
{
via->SetNetCode( findStitchedZoneNet( via ) );
via->SetIsFree( via->GetNetCode() > 0 );
}
if( !m_allowDRCViolations && checkDRCViolation( via ) )
if( checkDRCViolation( via ) )
{
m_frame->ShowInfoBarError( _( "Via location violates DRC." ), true,
WX_INFOBAR::MESSAGE_TYPE::DRC_VIOLATION );
via->SetNetCode( 0 );
return false;
if( !m_allowDRCViolations )
return false;
}
else
{
@ -3021,12 +3031,6 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent )
infobar->Dismiss();
}
if( !track && !pad )
{
via->SetNetCode( findStitchedZoneNet( via ) );
via->SetIsFree();
}
aCommit.Add( via );
if( track )