pcbnew: Deselect all items in a delete commit at once

Deselecting each individually had the side-effect of possibly re-drawing
the view in between actions, leading to visible artifacts in the router
(where invisible items are set visible before committing a change)
This commit is contained in:
Seth Hillbrand 2018-09-26 05:41:14 -07:00
parent f68581d463
commit 491098af35
1 changed files with 12 additions and 9 deletions

View File

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