From 4bc4dc80b6997c7503d232cca1ec3b7b24a7d8ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20W=C5=82ostowski?= Date: Thu, 29 Sep 2016 18:58:22 +0200 Subject: [PATCH] pns: unique_ptr for BOARD_COMMIT member --- pcbnew/router/pns_kicad_iface.cpp | 8 ++------ pcbnew/router/pns_kicad_iface.h | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 78aa147b4b..67340d0100 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -414,13 +414,11 @@ PNS_KICAD_IFACE::PNS_KICAD_IFACE() m_world = nullptr; m_router = nullptr; m_debugDecorator = nullptr; - m_commit = nullptr; } PNS_KICAD_IFACE::~PNS_KICAD_IFACE() { - delete m_commit; delete m_ruleResolver; delete m_debugDecorator; @@ -823,7 +821,6 @@ void PNS_KICAD_IFACE::RemoveItem( PNS::ITEM* aItem ) if( parent ) { - assert( m_commit ); m_commit->Remove( parent ); } } @@ -873,7 +870,6 @@ void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem ) aItem->SetParent( newBI ); newBI->ClearFlags(); - assert( m_commit ); m_commit->Add( newBI ); } } @@ -882,6 +878,7 @@ void PNS_KICAD_IFACE::AddItem( PNS::ITEM* aItem ) void PNS_KICAD_IFACE::Commit() { 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; - delete m_commit; - m_commit = new BOARD_COMMIT( aFrame ); + m_commit.reset( new BOARD_COMMIT ( m_frame ) ); } diff --git a/pcbnew/router/pns_kicad_iface.h b/pcbnew/router/pns_kicad_iface.h index 3550f827b3..7d5280713c 100644 --- a/pcbnew/router/pns_kicad_iface.h +++ b/pcbnew/router/pns_kicad_iface.h @@ -76,7 +76,7 @@ private: BOARD* m_board; PICKED_ITEMS_LIST m_undoBuffer; PCB_EDIT_FRAME* m_frame; - BOARD_COMMIT* m_commit; + std::unique_ptr m_commit; }; #endif