PNS: Add defensive coding to AlternateShape()

Adds additional check/warnings about missing alternate shapes when they
are expected.

Fixes https://gitlab.com/kicad/code/kicad/issues/5233
This commit is contained in:
Seth Hillbrand 2020-08-19 06:56:08 -07:00
parent 87b078927c
commit dd9f7c8c25
2 changed files with 26 additions and 5 deletions

View File

@ -34,13 +34,24 @@ void INDEX::Add( ITEM* aItem )
for( int i = range.Start(); i <= range.End(); ++i ) for( int i = range.Start(); i <= range.End(); ++i )
{ {
if( ROUTER::GetInstance()->GetInterface()->IsPadOnLayer( aItem, i ) if( !ROUTER::GetInstance()->GetInterface()->IsPadOnLayer( aItem, i ) )
&& aItem->AlternateShape() ) {
if( aItem->AlternateShape() )
m_subIndices[i].Add( aItem, aItem->AlternateShape()->BBox() ); m_subIndices[i].Add( aItem, aItem->AlternateShape()->BBox() );
else else
{
wxLogError( "Missing expected Alternate shape for %s at %d %d",
aItem->Parent()->GetClass(), aItem->Anchor( 0 ).x, aItem->Anchor( 0 ).y );
m_subIndices[i].Add( aItem ); m_subIndices[i].Add( aItem );
} }
}
else
{
m_subIndices[i].Add( aItem );
}
}
m_allItems.insert( aItem ); m_allItems.insert( aItem );
int net = aItem->Net(); int net = aItem->Net();

View File

@ -45,12 +45,22 @@ bool ITEM::collideSimple( const ITEM* aOther, int aClearance, bool aNeedMTV, VEC
if( !aOther->Layers().IsMultilayer() if( !aOther->Layers().IsMultilayer()
&& !ROUTER::GetInstance()->GetInterface()->IsPadOnLayer( this, aOther->Layer() ) ) && !ROUTER::GetInstance()->GetInterface()->IsPadOnLayer( this, aOther->Layer() ) )
{ {
if( !AlternateShape() )
wxLogError
( "Missing expected Alternate shape for %s at %d %d", m_parent->GetClass(),
Anchor( 0 ).x, Anchor( 0 ).y );
else
shapeA = AlternateShape(); shapeA = AlternateShape();
} }
if( !Layers().IsMultilayer() if( !Layers().IsMultilayer()
&& !ROUTER::GetInstance()->GetInterface()->IsPadOnLayer( aOther, Layer() ) ) && !ROUTER::GetInstance()->GetInterface()->IsPadOnLayer( aOther, Layer() ) )
{ {
if( !aOther->AlternateShape() )
wxLogError
( "Missing expected Alternate shape for %s at %d %d", aOther->Parent()->GetClass(),
aOther->Anchor( 0 ).x, aOther->Anchor( 0 ).y );
else
shapeB = aOther->AlternateShape(); shapeB = aOther->AlternateShape();
} }