From 59807d8d26125e721bc6a6b303c23403c5a3d713 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Tue, 9 Nov 2021 00:00:54 -0500 Subject: [PATCH] A better solution to discarding pending shove operations Fixes https://gitlab.com/kicad/code/kicad/-/issues/9553 --- pcbnew/router/pns_line_placer.cpp | 7 +++++++ pcbnew/router/pns_router.cpp | 9 --------- pcbnew/router/pns_router.h | 1 - pcbnew/router/pns_shove.cpp | 12 ++++++++++++ pcbnew/router/pns_shove.h | 1 + pcbnew/router/router_tool.cpp | 16 +++------------- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 5119f47d83..140ab0198b 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -1468,6 +1468,13 @@ bool LINE_PLACER::HasPlacedAnything() const bool LINE_PLACER::CommitPlacement() { + if( Settings().Mode() == PNS::RM_Shove || Settings().Mode() == PNS::RM_Smart ) + { + m_shove->RewindToLastLockedNode(); + m_lastNode = m_shove->CurrentNode(); + m_lastNode->KillChildren(); + } + if( m_lastNode ) Router()->CommitRouting( m_lastNode ); diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index dfcd81ac5c..53d5c03db3 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -705,15 +705,6 @@ void ROUTER::CommitRouting() } -void ROUTER::AbortRouting() -{ - if( m_state == ROUTE_TRACK ) - m_placer->AbortPlacement(); - - StopRouting(); -} - - void ROUTER::StopRouting() { // Update the ratsnest with new changes diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index 99e36e85d2..5053a472d9 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -148,7 +148,6 @@ public: void UndoLastSegment(); void CommitRouting(); void StopRouting(); - void AbortRouting(); void ClearViewDecorations(); NODE* GetWorld() const { return m_world.get(); } diff --git a/pcbnew/router/pns_shove.cpp b/pcbnew/router/pns_shove.cpp index 16a911e84a..ea68c4ac85 100644 --- a/pcbnew/router/pns_shove.cpp +++ b/pcbnew/router/pns_shove.cpp @@ -1838,6 +1838,18 @@ bool SHOVE::RewindSpringbackTo( NODE* aNode ) } +bool SHOVE::RewindToLastLockedNode() +{ + if( m_nodeStack.empty() ) + return false; + + while( !m_nodeStack.back().m_locked && m_nodeStack.size() > 1 ) + m_nodeStack.pop_back(); + + return m_nodeStack.back().m_locked; +} + + void SHOVE::UnlockSpringbackNode( NODE* aNode ) { auto iter = m_nodeStack.begin(); diff --git a/pcbnew/router/pns_shove.h b/pcbnew/router/pns_shove.h index c3ed7c5037..8f032f2125 100644 --- a/pcbnew/router/pns_shove.h +++ b/pcbnew/router/pns_shove.h @@ -88,6 +88,7 @@ public: bool AddLockedSpringbackNode( NODE* aNode ); void UnlockSpringbackNode( NODE* aNode ); bool RewindSpringbackTo( NODE* aNode ); + bool RewindToLastLockedNode(); private: typedef std::vector HULL_SET; diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index a727ad1c73..23a0264526 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1144,8 +1144,6 @@ void ROUTER_TOOL::performRouting() // Set initial cursor setCursor(); - bool abortRouting = false; - while( TOOL_EVENT* evt = Wait() ) { setCursor(); @@ -1236,13 +1234,8 @@ void ROUTER_TOOL::performRouting() || evt->IsUndoRedo() || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) ) { - if( evt->IsCancelInteractive() ) - { - if( m_router->RoutingInProgress() ) - abortRouting = true; - else - m_cancelled = true; - } + if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() ) + m_cancelled = true; if( evt->IsActivate() && !evt->IsMoveTool() ) m_cancelled = true; @@ -1259,10 +1252,7 @@ void ROUTER_TOOL::performRouting() } } - if( abortRouting ) - m_router->AbortRouting(); - else - m_router->CommitRouting(); + m_router->CommitRouting(); finishInteractive(); }