diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index b9f8a634e2..b7a6faca94 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -61,12 +61,12 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a { // Objects potentially interested in changes: PICKED_ITEMS_LIST undoList; - KIGFX::VIEW* view = m_toolMgr->GetView(); - BOARD* board = (BOARD*) m_toolMgr->GetModel(); - PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) m_toolMgr->GetEditFrame(); - auto connectivity = board->GetConnectivity(); - std::set savedModules; - std::vector itemsToRemove; + KIGFX::VIEW* view = m_toolMgr->GetView(); + BOARD* board = (BOARD*) m_toolMgr->GetModel(); + PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) m_toolMgr->GetEditFrame(); + auto connectivity = board->GetConnectivity(); + std::set savedModules; + std::vector itemsToDeselect; if( Empty() ) return; @@ -142,11 +142,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a case CHT_REMOVE: { if( !m_editModules && aCreateUndoEntry ) - { undoList.PushItem( ITEM_PICKER( boardItem, UR_DELETED ) ); - } - - itemsToRemove.push_back( boardItem ); switch( boardItem->Type() ) { @@ -213,6 +209,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a case PCB_MARKER_T: // a marker used to show something case PCB_SEGZONE_T: // SEG_ZONE items are now deprecated case PCB_ZONE_AREA_T: + itemsToDeselect.push_back( boardItem ); + view->Remove( boardItem ); if( !( changeFlags & CHT_DONE ) ) @@ -274,11 +272,11 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a } } - // Removing an item should trigger the unselect action - // but only after all items are removed otherwise we can get - // flickering depending on the system - if( itemsToRemove.size() > 0 ) - m_toolMgr->RunAction( PCB_ACTIONS::unselectItems, true, &itemsToRemove ); + // Removing an item should trigger the unselect action + // but only after all items are removed otherwise we can get + // flickering depending on the system + if( itemsToDeselect.size() > 0 ) + m_toolMgr->RunAction( PCB_ACTIONS::unselectItems, true, &itemsToDeselect ); if( !m_editModules && aCreateUndoEntry ) frame->SaveCopyInUndoList( undoList, UR_UNSPECIFIED );