From 46314f6483091715d4119deff7ce8a2319df23f3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 19 Dec 2020 23:19:38 +0000 Subject: [PATCH] Only compare collision-corrected routes when looking for shortest. Fixes https://gitlab.com/kicad/code/kicad/issues/6511 --- pcbnew/router/pns_line_placer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 7692116c65..fa2d8ddf13 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -477,7 +477,8 @@ bool LINE_PLACER::rhWalkOnly( const VECTOR2I& aP, LINE& aNewHead ) bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead ) { - LINE newHead( m_head ), bestHead( m_head ); + LINE newHead( m_head ); + LINE bestHead( m_head ); bool hasBest = false; buildInitialLine( aP, newHead ); @@ -503,7 +504,7 @@ bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead ) // We want the shortest line here to ensure we don't break a clearance // rule on larger, overlapping items (e.g. vias) - if( newHead.CLine().Length() < bestHead.CLine().Length() ) + if( !hasBest || newHead.CLine().Length() < bestHead.CLine().Length() ) { bestHead = newHead; hasBest = true;