From 153594b9eadca9810d40613adfb2e26ae6cf53cc Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 31 Oct 2021 16:06:57 -0400 Subject: [PATCH] PNS: Actually implement the AbortRouting API Fixes https://gitlab.com/kicad/code/kicad/-/issues/9425 --- pcbnew/router/pns_router.cpp | 9 +++++++++ pcbnew/router/pns_router.h | 1 + pcbnew/router/router_tool.cpp | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 3d98364854..9c438b6fa4 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -705,6 +705,15 @@ 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 b672db2500..a3cccb1c27 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -148,6 +148,7 @@ public: void UndoLastSegment(); void CommitRouting(); void StopRouting(); + void AbortRouting(); void ClearViewDecorations(); NODE* GetWorld() const { return m_world.get(); } diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 44881cd9b6..ec253658b8 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -1144,6 +1144,8 @@ void ROUTER_TOOL::performRouting() // Set initial cursor setCursor(); + bool abortRouting = false; + while( TOOL_EVENT* evt = Wait() ) { setCursor(); @@ -1234,8 +1236,13 @@ void ROUTER_TOOL::performRouting() || evt->IsUndoRedo() || evt->IsAction( &PCB_ACTIONS::routerInlineDrag ) ) { - if( evt->IsCancelInteractive() && !m_router->RoutingInProgress() ) - m_cancelled = true; + if( evt->IsCancelInteractive() ) + { + if( m_router->RoutingInProgress() ) + abortRouting = true; + else + m_cancelled = true; + } if( evt->IsActivate() && !evt->IsMoveTool() ) m_cancelled = true; @@ -1252,7 +1259,10 @@ void ROUTER_TOOL::performRouting() } } - m_router->CommitRouting(); + if( abortRouting ) + m_router->AbortRouting(); + else + m_router->CommitRouting(); finishInteractive(); }