From 2bd735b631b83461ab1a1e892ab510c6f7fdd0c6 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 9 Jul 2021 10:25:19 +0100 Subject: [PATCH] A little more safety in setting the router idle mode. Fixes https://gitlab.com/kicad/code/kicad/issues/8765 --- pcbnew/router/pns_router.cpp | 21 ++++++++++----------- pcbnew/router/pns_router.h | 27 +++++++-------------------- 2 files changed, 17 insertions(+), 31 deletions(-) diff --git a/pcbnew/router/pns_router.cpp b/pcbnew/router/pns_router.cpp index 734e61e48e..e65758f89a 100644 --- a/pcbnew/router/pns_router.cpp +++ b/pcbnew/router/pns_router.cpp @@ -188,6 +188,7 @@ bool ROUTER::StartDragging( const VECTOR2I& aP, ITEM_SET aStartItems, int aDragM if( m_dragger->Start( aP, aStartItems ) ) { m_state = DRAG_SEGMENT; + return true; } else { @@ -195,8 +196,6 @@ bool ROUTER::StartDragging( const VECTOR2I& aP, ITEM_SET aStartItems, int aDragM m_state = IDLE; return false; } - - return true; } @@ -412,21 +411,21 @@ bool ROUTER::StartRouting( const VECTOR2I& aP, ITEM* aStartItem, int aLayer ) m_logger->Log( LOGGER::EVT_START_ROUTE, aP, aStartItem ); } - bool rv = m_placer->Start( aP, aStartItem ); - - if( !rv ) + if( m_placer->Start( aP, aStartItem ) ) + { + m_state = ROUTE_TRACK; + return true; + } + else + { + m_state = IDLE; return false; - - m_currentEnd = aP; - m_state = ROUTE_TRACK; - return rv; + } } void ROUTER::Move( const VECTOR2I& aP, ITEM* endItem ) { - m_currentEnd = aP; - if( m_logger ) m_logger->Log( LOGGER::EVT_MOVE, aP, endItem ); diff --git a/pcbnew/router/pns_router.h b/pcbnew/router/pns_router.h index 5102bc51cf..b672db2500 100644 --- a/pcbnew/router/pns_router.h +++ b/pcbnew/router/pns_router.h @@ -166,10 +166,7 @@ public: LOGGER* Logger(); - RULE_RESOLVER* GetRuleResolver() const - { - return m_iface->GetRuleResolver(); - } + RULE_RESOLVER* GetRuleResolver() const { return m_iface->GetRuleResolver(); } bool IsPlacingVia() const; @@ -207,20 +204,10 @@ public: PLACEMENT_ALGO* Placer() { return m_placer.get(); } - ROUTER_IFACE* GetInterface() const - { - return m_iface; - } + ROUTER_IFACE* GetInterface() const { return m_iface; } - void SetVisibleViewArea( const BOX2I& aExtents ) - { - m_visibleViewArea = aExtents; - } - - const BOX2I& VisibleViewArea() const - { - return m_visibleViewArea; - } + void SetVisibleViewArea( const BOX2I& aExtents ) { m_visibleViewArea = aExtents; } + const BOX2I& VisibleViewArea() const { return m_visibleViewArea; } private: void movePlacing( const VECTOR2I& aP, ITEM* aItem ); @@ -233,9 +220,9 @@ private: void markViolations( NODE* aNode, ITEM_SET& aCurrent, NODE::ITEM_VECTOR& aRemoved ); bool isStartingPointRoutable( const VECTOR2I& aWhere, ITEM* aItem, int aLayer ); - BOX2I m_visibleViewArea; - VECTOR2I m_currentEnd; - RouterState m_state; +private: + BOX2I m_visibleViewArea; + RouterState m_state; std::unique_ptr m_world; NODE* m_lastNode;