Be more cognizant of multi-layer items.

This commit is contained in:
Jeff Young 2022-03-01 11:55:59 +00:00
parent a4a3f6ff74
commit 661488e932
1 changed files with 8 additions and 5 deletions

View File

@ -359,7 +359,7 @@ void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent )
if( node && item && item != DELETED_BOARD_ITEM::GetInstance() ) if( node && item && item != DELETED_BOARD_ITEM::GetInstance() )
{ {
PCB_LAYER_ID principalLayer = item->GetLayer(); PCB_LAYER_ID principalLayer;
LSET violationLayers; LSET violationLayers;
std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem; std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
BOARD_ITEM* a = board->GetItem( rc_item->GetMainItemID() ); BOARD_ITEM* a = board->GetItem( rc_item->GetMainItemID() );
@ -385,19 +385,22 @@ void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent )
} }
else else
{ {
principalLayer = UNDEFINED_LAYER;
if( a || b || c || d ) if( a || b || c || d )
violationLayers = LSET::AllLayersMask(); violationLayers = LSET::AllLayersMask();
for( BOARD_ITEM* it: {a, b, c, d} ) // Try to initialize principalLayer to a valid layer. Note that some markers have
// a layer set to UNDEFINED_LAYER, so we may need to keep looking.
for( BOARD_ITEM* it: { a, b, c, d } )
{ {
if( !it ) if( !it )
continue; continue;
LSET layersList = getActiveLayers( it ); LSET layersList = getActiveLayers( it );
violationLayers &= layersList; violationLayers &= layersList;
// Try to initialize principalLayer to a valid layer
// Some markers have a layer set to UNDEFINED_LAYER, and setting
// principalLayer to a valid layer can be useful
if( principalLayer <= UNDEFINED_LAYER ) if( principalLayer <= UNDEFINED_LAYER )
principalLayer = layersList.Seq().front(); principalLayer = layersList.Seq().front();
} }