drc_test_provider_library_parity: fix a crash due to a incorrect if()...else() logic.

The incorrect logic allowed execution of the else sequence when it should not be executed.
This commit is contained in:
jean-pierre charras 2022-01-14 18:17:14 +01:00
parent a533d64417
commit bc77a1e2dd
1 changed files with 44 additions and 32 deletions

View File

@ -322,6 +322,8 @@ bool modelsNeedUpdate( const FP_3DMODEL& a, const FP_3DMODEL& b )
bool FOOTPRINT::FootprintNeedsUpdate( const FOOTPRINT* aLibFootprint ) bool FOOTPRINT::FootprintNeedsUpdate( const FOOTPRINT* aLibFootprint )
{ {
wxASSERT( aLibFootprint );
if( IsFlipped() ) if( IsFlipped() )
{ {
std::unique_ptr<FOOTPRINT> temp( static_cast<FOOTPRINT*>( Clone() ) ); std::unique_ptr<FOOTPRINT> temp( static_cast<FOOTPRINT*>( Clone() ) );
@ -444,26 +446,31 @@ bool DRC_TEST_PROVIDER_LIBRARY_PARITY::Run()
{ {
} }
if( !libTableRow && !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_ISSUES ) ) if( !libTableRow )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES ); if( !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_ISSUES ) )
msg.Printf( _( "The current configuration does not include the library '%s'." ), {
libName ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES );
drcItem->SetErrorMessage( msg ); msg.Printf( _( "The current configuration does not include the library '%s'." ),
drcItem->SetItems( footprint ); libName );
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER ); drcItem->SetErrorMessage( msg );
drcItem->SetItems( footprint );
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
}
continue; continue;
} }
else if( !libTable->HasLibrary( libName, true ) else if( !libTable->HasLibrary( libName, true ) )
&& !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_ISSUES ))
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES ); if( !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_ISSUES ) )
msg.Printf( _( "The library '%s' is not enabled in the current configuration." ), {
libName ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES );
drcItem->SetErrorMessage( msg ); msg.Printf( _( "The library '%s' is not enabled in the current configuration." ),
drcItem->SetItems( footprint ); libName );
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER ); drcItem->SetErrorMessage( msg );
drcItem->SetItems( footprint );
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
}
continue; continue;
} }
@ -489,26 +496,31 @@ bool DRC_TEST_PROVIDER_LIBRARY_PARITY::Run()
} }
} }
if( !libFootprint && !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_ISSUES ) ) if( !libFootprint )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES ); if( !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_ISSUES ) )
msg.Printf( "Footprint '%s' not found in library '%s'.", {
fpName, std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_ISSUES );
libName ); msg.Printf( "Footprint '%s' not found in library '%s'.",
drcItem->SetErrorMessage( msg ); fpName,
drcItem->SetItems( footprint ); libName );
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER ); drcItem->SetErrorMessage( msg );
drcItem->SetItems( footprint );
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
}
} }
else if( footprint->FootprintNeedsUpdate( libFootprint.get() ) else if( footprint->FootprintNeedsUpdate( libFootprint.get() ) )
&& !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_MISMATCH ))
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_MISMATCH ); if( !m_drcEngine->IsErrorLimitExceeded( DRCE_LIB_FOOTPRINT_MISMATCH ) )
msg.Printf( "Footprint '%s' does not match copy in library '%s'.", {
fpName, std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_LIB_FOOTPRINT_MISMATCH );
libName ); msg.Printf( "Footprint '%s' does not match copy in library '%s'.",
drcItem->SetErrorMessage( msg ); fpName,
drcItem->SetItems( footprint ); libName );
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER ); drcItem->SetErrorMessage( msg );
drcItem->SetItems( footprint );
reportViolation( drcItem, footprint->GetCenter(), UNDEFINED_LAYER );
}
} }
} }