From 932fdf86741bbf1f37a1758d90ac2b8090f9b84d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 28 Apr 2020 17:17:38 +0100 Subject: [PATCH] Fix issue with default netclass vs orphaned net netclass. --- pcbnew/board_connected_item.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pcbnew/board_connected_item.cpp b/pcbnew/board_connected_item.cpp index f94fdb392b..4e26463a80 100644 --- a/pcbnew/board_connected_item.cpp +++ b/pcbnew/board_connected_item.cpp @@ -81,15 +81,23 @@ bool BOARD_CONNECTED_ITEM::SetNetCode( int aNetCode, bool aNoAssert ) int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem, wxString* aSource ) const { - NETCLASSPTR netclass = GetNetClass(); - int myClearance = netclass->GetClearance(); + NETCLASSPTR netclass; - if( aSource ) - *aSource = wxString::Format( _( "%s netclass clearance" ), netclass->GetName() ); + // NB: we must check the net first, as when it is 0 GetNetClass() will return the + // orphaned net netclass, not the default netclass. + if( m_netinfo->GetNet() == 0 ) + netclass = GetBoard()->GetDesignSettings().GetDefault(); + else + netclass = GetNetClass(); + + int myClearance = netclass->GetClearance(); if( aItem && aItem->GetClearance() > myClearance ) return aItem->GetClearance( nullptr, aSource ); + if( aSource ) + *aSource = wxString::Format( _( "%s netclass clearance" ), netclass->GetName() ); + return myClearance; }