From e37488f1450b35cf9c8de3a4791b4c592d5ce5fd Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 7 Dec 2016 16:50:23 +0100 Subject: [PATCH] Minor code simplification in BOARD_COMMIT --- pcbnew/board_commit.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index a72d4ed46d..b5b23b9cae 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -70,6 +70,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage ) { int changeType = ent.m_type & CHT_TYPE; int changeFlags = ent.m_type & CHT_FLAGS; + bool done = changeFlags & CHT_DONE; BOARD_ITEM* boardItem = static_cast( ent.m_item ); // Module items need to be saved in the undo buffer before modification @@ -109,7 +110,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage ) { undoList.PushItem( ITEM_PICKER( boardItem, UR_NEW ) ); - if( !( changeFlags & CHT_DONE ) ) + if( !done ) board->Add( boardItem ); //ratsnest->Add( boardItem ); // TODO currently done by BOARD::Add() @@ -125,7 +126,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage ) // modules inside modules are not supported yet assert( boardItem->Type() != PCB_MODULE_T ); - if( !( changeFlags & CHT_DONE ) ) + if( !done ) board->m_Modules->Add( boardItem ); } @@ -136,9 +137,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage ) case CHT_REMOVE: { if( !m_editModules ) - { undoList.PushItem( ITEM_PICKER( boardItem, UR_DELETED ) ); - } switch( boardItem->Type() ) { @@ -182,7 +181,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage ) { view->Remove( boardItem ); - if( !( changeFlags & CHT_DONE ) ) + if( !done ) { MODULE* module = static_cast( boardItem->GetParent() ); assert( module && module->Type() == PCB_MODULE_T ); @@ -207,7 +206,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage ) case PCB_ZONE_AREA_T: view->Remove( boardItem ); - if( !( changeFlags & CHT_DONE ) ) + if( !done ) board->Remove( boardItem ); //ratsnest->Remove( boardItem ); // currently done by BOARD::Remove() @@ -224,7 +223,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage ) view->Remove( module ); - if( !( changeFlags & CHT_DONE ) ) + if( !done ) board->Remove( module ); // Clear flags to indicate, that the ratsnest, list of nets & pads are not valid anymore