From 94130716a5ca1e1e754008426b202eaa4b231d7d Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 14 May 2023 17:20:59 -0400 Subject: [PATCH] PNS: Collision search context may be null Fixes https://gitlab.com/kicad/code/kicad/-/issues/14741 --- pcbnew/router/pns_item.cpp | 3 ++- pcbnew/router/pns_line_placer.cpp | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pcbnew/router/pns_item.cpp b/pcbnew/router/pns_item.cpp index 8d4297f926..eab515ca36 100644 --- a/pcbnew/router/pns_item.cpp +++ b/pcbnew/router/pns_item.cpp @@ -139,7 +139,8 @@ bool ITEM::collideSimple( const ITEM* aHead, const NODE* aNode, } else { - clearance = aNode->GetClearance( this, aHead, aCtx->options.m_useClearanceEpsilon ); + clearance = aNode->GetClearance( this, aHead, + aCtx ? aCtx->options.m_useClearanceEpsilon : false ); } if( clearance >= 0 ) diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 42da0e85d4..9d83c7087a 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -598,7 +598,9 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio aViaOk = buildInitialLine( walkP, l1, round == 0 ); PNS_DBG( Dbg(), AddItem, &l1, BLUE, 20000, wxT( "walk-base-l1" ) ); - PNS_DBG( Dbg(), AddPoint, l1.Via().Pos(), BLUE, 100000, wxT( "walk-base-l1-via" ) ); + + if( l1.EndsWithVia() ) + PNS_DBG( Dbg(), AddPoint, l1.Via().Pos(), BLUE, 100000, wxT( "walk-base-l1-via" ) ); LINE initTrack( m_tail ); initTrack.Line().Append( l1.CLine() ); @@ -731,7 +733,12 @@ bool LINE_PLACER::rhWalkBase( const VECTOR2I& aP, LINE& aWalkLine, int aCollisio } PNS_DBG( Dbg(), AddItem, &walkFull, GREEN, 200000, wxT( "walk-full" ) ); - PNS_DBG( Dbg(), AddPoint, walkFull.Via().Pos(), GREEN, 200000, wxString::Format( "walk-via ok %d", aViaOk?1:0 ) ); + + if( walkFull.EndsWithVia() ) + { + PNS_DBG( Dbg(), AddPoint, walkFull.Via().Pos(), GREEN, 200000, + wxString::Format( "walk-via ok %d", aViaOk ? 1 : 0 ) ); + } aWalkLine = walkFull; @@ -987,8 +994,11 @@ bool LINE_PLACER::rhShoveOnly( const VECTOR2I& aP, LINE& aNewHead, LINE& aNewTai OPTIMIZER optimizer( m_currentNode ); - PNS_DBG( Dbg(), AddPoint, newHead.Via().Pos(), GREEN, 1000000, "shove-via-preopt" ); - PNS_DBG( Dbg(), AddPoint, newHead.Via().Pos(), GREEN, 1000000, "shove-via-postopt" ); + if( newHead.EndsWithVia() ) + { + PNS_DBG( Dbg(), AddPoint, newHead.Via().Pos(), GREEN, 1000000, "shove-via-preopt" ); + PNS_DBG( Dbg(), AddPoint, newHead.Via().Pos(), GREEN, 1000000, "shove-via-postopt" ); + } if( ! splitHeadTail( newHead, m_tail, aNewHead, aNewTail ) ) return false;