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; } }