From 38df9189938c1282adc89d63e4da67d83e75aa63 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 16 Feb 2024 10:06:50 -0800 Subject: [PATCH] Correct usage signature for PNS_NODE::Add() When moving a unique_ptr, you are actually passing the object, not a reference to the object. So we either std::move with the bare unique_ptr parameter or we pass a reference. But we should never pass an rvalue reference for this or we'll make a copy without holding the tracking (because it was moved) Fixes https://gitlab.com/kicad/code/kicad/-/issues/16839 (cherry picked from commit b2a25cb59e8d1def69eecf16142d6a732520bdff) --- pcbnew/router/pns_node.cpp | 10 +++++----- pcbnew/router/pns_node.h | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pcbnew/router/pns_node.cpp b/pcbnew/router/pns_node.cpp index 10af93f743..3bec2d8b1c 100644 --- a/pcbnew/router/pns_node.cpp +++ b/pcbnew/router/pns_node.cpp @@ -525,7 +525,7 @@ void NODE::addSolid( SOLID* aSolid ) } -void NODE::Add( std::unique_ptr< SOLID >&& aSolid ) +void NODE::Add( std::unique_ptr< SOLID > aSolid ) { aSolid->SetOwner( this ); addSolid( aSolid.release() ); @@ -560,7 +560,7 @@ void NODE::addHole( HOLE* aHole ) } -void NODE::Add( std::unique_ptr< VIA >&& aVia ) +void NODE::Add( std::unique_ptr< VIA > aVia ) { addVia( aVia.release() ); } @@ -654,7 +654,7 @@ void NODE::addSegment( SEGMENT* aSeg ) } -bool NODE::Add( std::unique_ptr< SEGMENT >&& aSegment, bool aAllowRedundant ) +bool NODE::Add( std::unique_ptr< SEGMENT > aSegment, bool aAllowRedundant ) { if( aSegment->Seg().A == aSegment->Seg().B ) { @@ -683,7 +683,7 @@ void NODE::addArc( ARC* aArc ) } -bool NODE::Add( std::unique_ptr< ARC >&& aArc, bool aAllowRedundant ) +bool NODE::Add( std::unique_ptr< ARC > aArc, bool aAllowRedundant ) { const SHAPE_ARC& arc = aArc->CArc(); @@ -835,7 +835,7 @@ void NODE::removeSolidIndex( SOLID* aSolid ) } -void NODE::Replace( ITEM* aOldItem, std::unique_ptr< ITEM >&& aNewItem ) +void NODE::Replace( ITEM* aOldItem, std::unique_ptr< ITEM > aNewItem ) { Remove( aOldItem ); add( aNewItem.release() ); diff --git a/pcbnew/router/pns_node.h b/pcbnew/router/pns_node.h index 1e0ee461fb..c2b1fc4433 100644 --- a/pcbnew/router/pns_node.h +++ b/pcbnew/router/pns_node.h @@ -323,10 +323,10 @@ public: * at the same coordinates as an existing one). * @return true if added */ - bool Add( std::unique_ptr< SEGMENT >&& aSegment, bool aAllowRedundant = false ); - void Add( std::unique_ptr< SOLID >&& aSolid ); - void Add( std::unique_ptr< VIA >&& aVia ); - bool Add( std::unique_ptr< ARC >&& aArc, bool aAllowRedundant = false ); + bool Add( std::unique_ptr aSegment, bool aAllowRedundant = false ); + void Add( std::unique_ptr aSolid ); + void Add( std::unique_ptr aVia ); + bool Add( std::unique_ptr aArc, bool aAllowRedundant = false ); void Add( LINE& aLine, bool aAllowRedundant = false ); @@ -355,7 +355,7 @@ public: * @param aOldItem item to be removed * @param aNewItem item add instead */ - void Replace( ITEM* aOldItem, std::unique_ptr< ITEM >&& aNewItem ); + void Replace( ITEM* aOldItem, std::unique_ptr< ITEM > aNewItem ); void Replace( LINE& aOldLine, LINE& aNewLine ); /**