Cleanup Undo ordering
The undo command has accreted a number of things over the years. This prunes back the changes to the minimum required number and correctly orders the actions Fixes https://gitlab.com/kicad/code/kicad/issues/14661
This commit is contained in:
parent
df7d62fdd3
commit
cb85412b85
|
@ -1182,35 +1182,21 @@ int SCH_EDITOR_CONTROL::Undo( const TOOL_EVENT& aEvent )
|
||||||
m_toolMgr->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_PRE, AS_GLOBAL } );
|
m_toolMgr->ProcessEvent( { TC_MESSAGE, TA_UNDO_REDO_PRE, AS_GLOBAL } );
|
||||||
|
|
||||||
// Get the old list
|
// Get the old list
|
||||||
PICKED_ITEMS_LIST* List = m_frame->PopCommandFromUndoList();
|
PICKED_ITEMS_LIST* undo_list = m_frame->PopCommandFromUndoList();
|
||||||
size_t num_undos = m_frame->m_undoList.m_CommandsList.size();
|
|
||||||
|
|
||||||
// The cleanup routines normally run after an operation and so attempt to append their
|
|
||||||
// undo items onto the operation's list. However, in this case that's going be the list
|
|
||||||
// under us, which we don't want, so we push a dummy list onto the stack.
|
|
||||||
PICKED_ITEMS_LIST* dummy = new PICKED_ITEMS_LIST();
|
|
||||||
m_frame->PushCommandToUndoList( dummy );
|
|
||||||
|
|
||||||
m_frame->PutDataInPreviousState( List );
|
|
||||||
|
|
||||||
|
m_frame->PutDataInPreviousState( undo_list );
|
||||||
m_frame->SetSheetNumberAndCount();
|
m_frame->SetSheetNumberAndCount();
|
||||||
m_frame->TestDanglingEnds();
|
m_frame->TestDanglingEnds();
|
||||||
m_frame->OnPageSettingsChange();
|
|
||||||
|
|
||||||
// The cleanup routines *should* have appended to our dummy list, but just to be doubly
|
|
||||||
// sure pop any other new lists off the stack as well
|
|
||||||
while( m_frame->m_undoList.m_CommandsList.size() > num_undos )
|
|
||||||
delete m_frame->PopCommandFromUndoList();
|
|
||||||
|
|
||||||
// Now push the old command to the RedoList
|
// Now push the old command to the RedoList
|
||||||
List->ReversePickersListOrder();
|
undo_list->ReversePickersListOrder();
|
||||||
m_frame->PushCommandToRedoList( List );
|
m_frame->PushCommandToRedoList( undo_list );
|
||||||
|
|
||||||
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
|
m_toolMgr->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
|
||||||
|
|
||||||
m_frame->SyncView();
|
m_frame->SyncView();
|
||||||
m_frame->GetCanvas()->Refresh();
|
|
||||||
m_frame->OnModify();
|
m_frame->OnModify();
|
||||||
|
m_frame->OnPageSettingsChange();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue