From 469fe76994c0fea1b66457f5b3ad677250dc0b4d Mon Sep 17 00:00:00 2001 From: Lucas Dumont Date: Mon, 17 Apr 2023 14:13:36 +1200 Subject: [PATCH] pcbnew: Fix crash with differential routing Fixes https://gitlab.com/kicad/code/kicad/-/issues/14537 --- pcbnew/router/pns_via.cpp | 3 ++- pcbnew/router/pns_via.h | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pcbnew/router/pns_via.cpp b/pcbnew/router/pns_via.cpp index ed35073a16..22a3713a28 100644 --- a/pcbnew/router/pns_via.cpp +++ b/pcbnew/router/pns_via.cpp @@ -140,7 +140,7 @@ const SHAPE_LINE_CHAIN VIA::Hull( int aClearance, int aWalkaroundThickness, int int cl = ( aClearance + aWalkaroundThickness / 2 ); int width = m_diameter; - if( !ROUTER::GetInstance()->GetInterface()->IsFlashedOnLayer( this, aLayer ) ) + if( m_hole && !ROUTER::GetInstance()->GetInterface()->IsFlashedOnLayer( this, aLayer ) ) width = m_hole->Radius() * 2; // Chamfer = width * ( 1 - sqrt(2)/2 ) for equilateral octagon @@ -160,6 +160,7 @@ VIA* VIA::Clone() const v->m_diameter = m_diameter; v->m_drill = m_drill; v->m_shape = SHAPE_CIRCLE( m_pos, m_diameter / 2 ); + delete v->m_hole; v->m_hole = m_hole->Clone(); v->m_rank = m_rank; v->m_marker = m_marker; diff --git a/pcbnew/router/pns_via.h b/pcbnew/router/pns_via.h index e330174037..fb6151536f 100644 --- a/pcbnew/router/pns_via.h +++ b/pcbnew/router/pns_via.h @@ -53,12 +53,12 @@ public: VIA() : LINKED_ITEM( VIA_T ) { - m_diameter = 2; // Dummy value - m_drill = 0; - m_viaType = VIATYPE::THROUGH; - m_isFree = false; + m_diameter = 2; // Dummy value + m_drill = 0; + m_viaType = VIATYPE::THROUGH; + m_isFree = false; m_isVirtual = false; - m_hole = nullptr; + m_hole = HOLE::MakeCircularHole( m_pos, m_diameter / 2 ); } VIA( const VECTOR2I& aPos, const LAYER_RANGE& aLayers, int aDiameter, int aDrill,