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
This commit is contained in:
Roberto Fernandez Bautista 2022-09-01 15:25:38 +02:00
parent b0aba0fdf3
commit 22f96bfd11
1 changed files with 11 additions and 1 deletions

View File

@ -1003,10 +1003,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(), AddItem, &m_last_head, CYAN, 10000, wxT( "apply-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
{