diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 55a3f44e4e..76a39a0166 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -66,6 +66,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) m_toolMgr->GetEditFrame(); auto connectivity = board->GetConnectivity(); std::set savedModules; + std::vector itemsToRemove; if( Empty() ) return; @@ -145,6 +146,8 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a undoList.PushItem( ITEM_PICKER( boardItem, UR_DELETED ) ); } + itemsToRemove.push_back( boardItem ); + switch( boardItem->Type() ) { // Module items @@ -166,9 +169,6 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a view->Remove( boardItem ); - // Removing an item should trigger the unselect - m_toolMgr->RunAction( PCB_ACTIONS::unselectItem, true, boardItem ); - if( !( changeFlags & CHT_DONE ) ) { MODULE* module = static_cast( boardItem->GetParent() ); @@ -192,9 +192,6 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a case PCB_ZONE_AREA_T: view->Remove( boardItem ); - // Removing an item should trigger the unselect - m_toolMgr->RunAction( PCB_ACTIONS::unselectItem, true, boardItem ); - if( !( changeFlags & CHT_DONE ) ) board->Remove( boardItem ); @@ -207,9 +204,6 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a MODULE* module = static_cast( boardItem ); view->Remove( module ); - - // Removing an item should trigger the unselect - m_toolMgr->RunAction( PCB_ACTIONS::unselectItem, true, boardItem ); module->ClearFlags(); if( !( changeFlags & CHT_DONE ) ) @@ -224,6 +218,7 @@ void BOARD_COMMIT::Push( const wxString& aMessage, bool aCreateUndoEntry, bool a wxASSERT( false ); break; } + break; } @@ -256,6 +251,14 @@ 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 ); + } + if( !m_editModules && aCreateUndoEntry ) frame->SaveCopyInUndoList( undoList, UR_UNSPECIFIED );