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,20 +442,27 @@ 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;
if( track )
{
int net = track->GetNetCode();
wxASSERT( net > 0 ); // Without a net how can it be a diff-pair? wxASSERT( net > 0 ); // Without a net how can it be a diff-pair?
for( const KIID& id : rc_item->GetIDs() ) for( const KIID& id : rc_item->GetIDs() )
{ {
auto* candidate = dynamic_cast<BOARD_CONNECTED_ITEM*>( board->GetItem( id ) ); auto* candidate = dynamic_cast<BOARD_CONNECTED_ITEM*>( board->GetItem( id ) );
wxASSERT( candidate );
if( candidate && candidate->GetNetCode() == net ) if( candidate && candidate->GetNetCode() == net )
items.push_back( candidate ); items.push_back( candidate );
} }
}
else
{
items.push_back( item );
}
m_frame->FocusOnItems( items, principalLayer ); m_frame->FocusOnItems( items, principalLayer );
} }