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 b2a25cb59e)
This commit is contained in:
Seth Hillbrand 2024-02-16 10:06:50 -08:00
parent f45df48498
commit 38df918993
2 changed files with 10 additions and 10 deletions

View File

@ -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() );

View File

@ -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<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 );
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 );
/**