From 18ac4ed8424ee1af7d71ab250e0ac94b747426fc Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 15 Apr 2022 13:56:58 +0100 Subject: [PATCH] Fix crash when selecting DRC marker (as opposed to one of its children). --- pcbnew/dialogs/dialog_drc.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 509b11a16e..7a2748ab62 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -442,19 +442,26 @@ void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent ) } else if( rc_item->GetErrorCode() == DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG ) { - BOARD_CONNECTED_ITEM* connectedItem = dynamic_cast( item ); - int net = connectedItem ? connectedItem->GetNetCode() : -1; + BOARD_CONNECTED_ITEM* track = dynamic_cast( item ); std::vector items; - wxASSERT( net > 0 ); // Without a net how can it be a diff-pair? - - for( const KIID& id : rc_item->GetIDs() ) + if( track ) { - auto* candidate = dynamic_cast( board->GetItem( id ) ); - wxASSERT( candidate ); + int net = track->GetNetCode(); - if( candidate && candidate->GetNetCode() == net ) - items.push_back( candidate ); + wxASSERT( net > 0 ); // Without a net how can it be a diff-pair? + + for( const KIID& id : rc_item->GetIDs() ) + { + auto* candidate = dynamic_cast( board->GetItem( id ) ); + + if( candidate && candidate->GetNetCode() == net ) + items.push_back( candidate ); + } + } + else + { + items.push_back( item ); } m_frame->FocusOnItems( items, principalLayer );