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 {