Fix crash when highlighting via

This commit is contained in:
Jon Evans 2020-10-13 21:45:09 -04:00
parent 19fb1a92ce
commit a0c0bda1db
1 changed files with 13 additions and 11 deletions

View File

@ -588,20 +588,15 @@ int PCB_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent )
bool highContrast = settings->GetHighContrast(); bool highContrast = settings->GetHighContrast();
PCB_LAYER_ID contrastLayer = settings->GetPrimaryHighContrastLayer(); PCB_LAYER_ID contrastLayer = settings->GetPrimaryHighContrastLayer();
for( int i = 0; i < collector.GetCount(); i++ ) for( int i = collector.GetCount() - 1; i >= 0; i-- )
{ {
LSET itemLayers = collector[i]->GetLayerSet(); LSET itemLayers = collector[i]->GetLayerSet();
if( ( itemLayers & LSET::AllCuMask() ).none() ) if( ( itemLayers & LSET::AllCuMask() ).none() ||
collector.Remove( i ); ( highContrast && !itemLayers.Contains( contrastLayer ) ) )
if( highContrast && !itemLayers.Contains( contrastLayer ) )
collector.Remove( i );
if( collector[i]->Type() == PCB_PAD_T )
{ {
m_frame->SendMessageToEESCHEMA( static_cast<BOARD_CONNECTED_ITEM*>( collector[i] ) ); collector.Remove( i );
break; continue;
} }
} }
@ -609,7 +604,14 @@ int PCB_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent )
// Obtain net code for the clicked item // Obtain net code for the clicked item
if( enableHighlight ) if( enableHighlight )
net = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] )->GetNetCode(); {
BOARD_CONNECTED_ITEM* targetItem = static_cast<BOARD_CONNECTED_ITEM*>( collector[0] );
if( targetItem->Type() == PCB_PAD_T )
m_frame->SendMessageToEESCHEMA( targetItem );
net = targetItem->GetNetCode();
}
} }
auto& netcodes = settings->GetHighlightNetCodes(); auto& netcodes = settings->GetHighlightNetCodes();