From 1c85751bf008d15bb29cfac61a662203a4529986 Mon Sep 17 00:00:00 2001 From: Jon Evans <jon@craftyjon.com> Date: Thu, 13 Feb 2025 21:53:49 -0500 Subject: [PATCH] PNS: Use HasHole to check if an item has a hole Just checking Hole() for nullptr isn't valid Fixes https://gitlab.com/kicad/code/kicad/-/issues/19948 --- pcbnew/router/pns_item.cpp | 4 ++-- pcbnew/router/router_preview_item.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pcbnew/router/pns_item.cpp b/pcbnew/router/pns_item.cpp index 130736a054..5cbaf70906 100644 --- a/pcbnew/router/pns_item.cpp +++ b/pcbnew/router/pns_item.cpp @@ -150,12 +150,12 @@ bool ITEM::collideSimple( const ITEM* aHead, const NODE* aNode, int aLayer, } // And a special case for the "head" via's hole. - if( holeH && shouldWeConsiderHoleCollisions( this, holeH ) ) + if( aHead->HasHole() && shouldWeConsiderHoleCollisions( this, holeH ) ) { if( Net() != holeH->Net() && collideSimple( holeH, aNode, aLayer, aCtx ) ) collisionsFound = true; } - if( holeI && shouldWeConsiderHoleCollisions( holeI, aHead ) ) + if( HasHole() && shouldWeConsiderHoleCollisions( holeI, aHead ) ) { collisionsFound |= holeI->collideSimple( aHead, aNode, aLayer, aCtx ); } diff --git a/pcbnew/router/router_preview_item.cpp b/pcbnew/router/router_preview_item.cpp index 6f9cd21e0e..14b527f228 100644 --- a/pcbnew/router/router_preview_item.cpp +++ b/pcbnew/router/router_preview_item.cpp @@ -69,7 +69,7 @@ ROUTER_PREVIEW_ITEM::ROUTER_PREVIEW_ITEM( const PNS::ITEM* aItem, PNS::ROUTER_IF // TODO(JE) padstacks -- need to know the layer here m_shape = aItem->Shape( -1 )->Clone(); - if( aItem->Hole() ) + if( aItem->HasHole() ) m_hole = aItem->Hole()->Shape( -1 )->Clone(); } @@ -187,7 +187,7 @@ void ROUTER_PREVIEW_ITEM::Update( const PNS::ITEM* aItem ) delete m_hole; m_hole = nullptr; - if( aItem->Hole() ) + if( aItem->HasHole() ) m_hole = aItem->Hole()->Shape( -1 )->Clone(); break;