From 75ce97e260a0907bced3d334f842bc88278168b7 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 7 Jun 2021 20:34:00 -0400 Subject: [PATCH] Fix the last cause of duplicate segments when completing a route Fixes https://gitlab.com/kicad/code/kicad/-/issues/6863 --- pcbnew/router/pns_line_placer.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 4f08bac97e..f58c5bb4d9 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -1344,8 +1344,11 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinis seg.SetWidth( pl.Width() ); seg.SetLayer( m_currentLayer ); - if( m_lastNode->Add( std::make_unique( seg ) ) ) - lastItem = &seg; + std::unique_ptr sp = std::make_unique( seg ); + lastItem = sp.get(); + + if( !m_lastNode->Add( std::move( sp ) ) ) + lastItem = nullptr; } else { @@ -1356,8 +1359,10 @@ bool LINE_PLACER::FixRoute( const VECTOR2I& aP, ITEM* aEndItem, bool aForceFinis arc.SetWidth( pl.Width() ); arc.SetLayer( m_currentLayer ); - m_lastNode->Add( std::make_unique( arc ) ); - lastItem = &arc; + std::unique_ptr ap = std::make_unique( arc ); + lastItem = ap.get(); + + m_lastNode->Add( std::move( ap ) ); lastArc = arcIndex; } }