Fix crash when selecting DRC marker (as opposed to one of its children).

This commit is contained in:
Jeff Young 2022-04-15 13:56:58 +01:00
parent e9da8c3a00
commit 18ac4ed842
1 changed files with 16 additions and 9 deletions

View File

@ -442,19 +442,26 @@ void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent )
} }
else if( rc_item->GetErrorCode() == DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG ) else if( rc_item->GetErrorCode() == DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG )
{ {
BOARD_CONNECTED_ITEM* connectedItem = dynamic_cast<PCB_TRACK*>( item ); BOARD_CONNECTED_ITEM* track = dynamic_cast<PCB_TRACK*>( item );
int net = connectedItem ? connectedItem->GetNetCode() : -1;
std::vector<BOARD_ITEM*> items; std::vector<BOARD_ITEM*> items;
wxASSERT( net > 0 ); // Without a net how can it be a diff-pair? if( track )
for( const KIID& id : rc_item->GetIDs() )
{ {
auto* candidate = dynamic_cast<BOARD_CONNECTED_ITEM*>( board->GetItem( id ) ); int net = track->GetNetCode();
wxASSERT( candidate );
if( candidate && candidate->GetNetCode() == net ) wxASSERT( net > 0 ); // Without a net how can it be a diff-pair?
items.push_back( candidate );
for( const KIID& id : rc_item->GetIDs() )
{
auto* candidate = dynamic_cast<BOARD_CONNECTED_ITEM*>( board->GetItem( id ) );
if( candidate && candidate->GetNetCode() == net )
items.push_back( candidate );
}
}
else
{
items.push_back( item );
} }
m_frame->FocusOnItems( items, principalLayer ); m_frame->FocusOnItems( items, principalLayer );