mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
Don't clear the undo/redo list when we're just trimming it.
We only allow a certain number of commands on the lists and trim them when they overflow. PCB_BASE_EDIT_FRAME and PL_EDITOR_FRAME implemented this correctly; SCH_EDIT_FRAME and SYMBOL_EDIT_FRAME did not.
This commit is contained in:
parent
98bc03919d
commit
bce372c8a3
@ -474,18 +474,29 @@ void SCH_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCou
|
|||||||
if( aItemCount == 0 )
|
if( aItemCount == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
|
UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
|
||||||
|
|
||||||
for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
|
if( aItemCount < 0 )
|
||||||
{
|
{
|
||||||
command->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
|
list.ClearCommandList();
|
||||||
{
|
|
||||||
delete aItem;
|
|
||||||
} );
|
|
||||||
delete command;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( int ii = 0; ii < aItemCount; ii++ )
|
||||||
|
{
|
||||||
|
if( list.m_CommandsList.size() == 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
list.m_CommandsList.clear();
|
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
||||||
|
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
||||||
|
|
||||||
|
curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
|
||||||
|
{
|
||||||
|
delete aItem;
|
||||||
|
} );
|
||||||
|
delete curr_cmd; // Delete command
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1556,18 +1556,29 @@ void SYMBOL_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItem
|
|||||||
if( aItemCount == 0 )
|
if( aItemCount == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
|
UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
|
||||||
|
|
||||||
for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
|
if( aItemCount < 0 )
|
||||||
{
|
{
|
||||||
command->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
|
list.ClearCommandList();
|
||||||
{
|
|
||||||
delete aItem;
|
|
||||||
} );
|
|
||||||
delete command;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( int ii = 0; ii < aItemCount; ii++ )
|
||||||
|
{
|
||||||
|
if( list.m_CommandsList.size() == 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
list.m_CommandsList.clear();
|
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
||||||
|
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
||||||
|
|
||||||
|
curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
|
||||||
|
{
|
||||||
|
delete aItem;
|
||||||
|
} );
|
||||||
|
delete curr_cmd; // Delete command
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -934,25 +934,28 @@ void PL_EDITOR_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCo
|
|||||||
if( aItemCount == 0 )
|
if( aItemCount == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
|
UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
|
||||||
unsigned icnt = list.m_CommandsList.size();
|
|
||||||
|
|
||||||
if( aItemCount > 0 )
|
if( aItemCount < 0 )
|
||||||
icnt = aItemCount;
|
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < icnt; ii++ )
|
|
||||||
{
|
{
|
||||||
if( list.m_CommandsList.size() == 0 )
|
list.ClearCommandList();
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( int ii = 0; ii < aItemCount; ii++ )
|
||||||
|
{
|
||||||
|
if( list.m_CommandsList.size() == 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
||||||
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
||||||
|
|
||||||
curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
|
curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
|
||||||
{
|
{
|
||||||
delete aItem;
|
delete aItem;
|
||||||
} );
|
} );
|
||||||
delete curr_cmd; // Delete command
|
delete curr_cmd; // Delete command
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,21 +503,24 @@ void PCB_BASE_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aIt
|
|||||||
if( aItemCount == 0 )
|
if( aItemCount == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
|
UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
|
||||||
unsigned icnt = list.m_CommandsList.size();
|
|
||||||
|
|
||||||
if( aItemCount > 0 )
|
if( aItemCount < 0 )
|
||||||
icnt = aItemCount;
|
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < icnt; ii++ )
|
|
||||||
{
|
{
|
||||||
if( list.m_CommandsList.size() == 0 )
|
list.ClearCommandList();
|
||||||
break;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for( int ii = 0; ii < aItemCount; ii++ )
|
||||||
|
{
|
||||||
|
if( list.m_CommandsList.size() == 0 )
|
||||||
|
break;
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
||||||
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
||||||
ClearListAndDeleteItems( curr_cmd );
|
ClearListAndDeleteItems( curr_cmd );
|
||||||
delete curr_cmd; // Delete command
|
delete curr_cmd; // Delete command
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user