router: GetUpdatedItems() now returns an unique_ptr to the temporary NODE so that the items it owns do not get deleted upon return from the method

This commit is contained in:
Tomasz Wlostowski 2022-11-18 15:09:24 +01:00
parent 644c76b9c6
commit 24c271d508
3 changed files with 6 additions and 7 deletions

View File

@ -769,7 +769,7 @@ bool ROUTER::movePlacing( const VECTOR2I& aP, ITEM* aEndItem )
return ret;
}
bool ROUTER::GetUpdatedItems( std::vector<PNS::ITEM*>& aRemoved, std::vector<PNS::ITEM*>& aAdded )
std::unique_ptr<NODE> ROUTER::GetUpdatedItems( std::vector<PNS::ITEM*>& aRemoved, std::vector<PNS::ITEM*>& aAdded )
{
NODE *node;
ITEM_SET current;
@ -794,10 +794,8 @@ bool ROUTER::GetUpdatedItems( std::vector<PNS::ITEM*>& aRemoved, std::vector<PNS
}
tmpNode->GetUpdatedItems( aRemoved, aAdded );
//printf("added %d removed %d\n", aRemoved.size(), aAdded.size() );
return true;
return std::move( tmpNode );
}
void ROUTER::CommitRouting( NODE* aNode )

View File

@ -150,7 +150,7 @@ public:
void UndoLastSegment();
void CommitRouting();
bool GetUpdatedItems( std::vector<PNS::ITEM*>& aRemoved, std::vector<PNS::ITEM*>& aAdded );
std::unique_ptr<NODE> GetUpdatedItems( std::vector<PNS::ITEM*>& aRemoved, std::vector<PNS::ITEM*>& aAdded );
void StopRouting();
void ClearViewDecorations();

View File

@ -608,8 +608,9 @@ void ROUTER_TOOL::saveRouterDebugLog()
prj->GetProjectFile().SaveAs( cwd, "pns" );
std::vector<PNS::ITEM*> added, removed;
auto tmpNode = m_router->GetUpdatedItems( removed, added );
if( !m_router->GetUpdatedItems( removed, added ) )
if( !tmpNode )
{
fclose( f );
return;