pns: unique_ptr for BOARD_COMMIT member

This commit is contained in:
Tomasz Włostowski 2016-09-29 18:58:22 +02:00 committed by Maciej Suminski
parent 2b7e6e73ec
commit 4bc4dc80b6
2 changed files with 3 additions and 7 deletions

View File

@ -414,13 +414,11 @@ PNS_KICAD_IFACE::PNS_KICAD_IFACE()
m_world = nullptr; m_world = nullptr;
m_router = nullptr; m_router = nullptr;
m_debugDecorator = nullptr; m_debugDecorator = nullptr;
m_commit = nullptr;
} }
PNS_KICAD_IFACE::~PNS_KICAD_IFACE() PNS_KICAD_IFACE::~PNS_KICAD_IFACE()
{ {
delete m_commit;
delete m_ruleResolver; delete m_ruleResolver;
delete m_debugDecorator; delete m_debugDecorator;
@ -823,7 +821,6 @@ void PNS_KICAD_IFACE::RemoveItem( PNS::ITEM* aItem )
if( parent ) if( parent )
{ {
assert( m_commit );
m_commit->Remove( parent ); m_commit->Remove( parent );
} }
} }
@ -873,7 +870,6 @@ void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem )
aItem->SetParent( newBI ); aItem->SetParent( newBI );
newBI->ClearFlags(); newBI->ClearFlags();
assert( m_commit );
m_commit->Add( newBI ); m_commit->Add( newBI );
} }
} }
@ -882,6 +878,7 @@ void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem )
void PNS_KICAD_IFACE::Commit() void PNS_KICAD_IFACE::Commit()
{ {
m_commit->Push( wxT( "Added a track" ) ); m_commit->Push( wxT( "Added a track" ) );
m_commit.reset( new BOARD_COMMIT ( m_frame ) );
} }
@ -927,6 +924,5 @@ void PNS_KICAD_IFACE::SetHostFrame( PCB_EDIT_FRAME* aFrame )
{ {
m_frame = aFrame; m_frame = aFrame;
delete m_commit; m_commit.reset( new BOARD_COMMIT ( m_frame ) );
m_commit = new BOARD_COMMIT( aFrame );
} }

View File

@ -76,7 +76,7 @@ private:
BOARD* m_board; BOARD* m_board;
PICKED_ITEMS_LIST m_undoBuffer; PICKED_ITEMS_LIST m_undoBuffer;
PCB_EDIT_FRAME* m_frame; PCB_EDIT_FRAME* m_frame;
BOARD_COMMIT* m_commit; std::unique_ptr<BOARD_COMMIT> m_commit;
}; };
#endif #endif