From 83305dd407e96a7f5f7494193d087651f828b37e Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Thu, 1 Sep 2022 15:25:38 +0200 Subject: [PATCH] Re-route m_last_head after routing fails This should ensure the shove state gets reverted Fixes https://gitlab.com/kicad/code/kicad/-/issues/9023 --- pcbnew/router/pns_line_placer.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index cad6cfacac..0f96eb1e22 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -971,9 +971,20 @@ void LINE_PLACER::routeStep( const VECTOR2I& aP ) if( fail ) { + PNS_DBG( Dbg(), Message, "routeStep failed" ); + if( m_last_head.PointCount() > 0 ) { m_head = m_last_head; + PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 100000, "head-before-re-route" ); + + VECTOR2I lastValidRoutePoint = m_head.CPoint( m_head.PointCount() - 1 ); + + // Re-route, so the shove state gets reverted + if( !routeHead( lastValidRoutePoint, m_head ) ) + PNS_DBG( Dbg(), Message, "****Unable to recover.***** Route head failed, second time" ); + + PNS_DBG( Dbg(), AddLine, m_head.CLine(), GREEN, 100000, "head-after-re-route" ); } else {