Make undo/redo lists protected.
This commit is contained in:
parent
fa9937701f
commit
1cd2a51db2
|
@ -796,14 +796,14 @@ bool EDA_BASE_FRAME::IsContentModified()
|
||||||
|
|
||||||
void EDA_BASE_FRAME::ClearUndoRedoList()
|
void EDA_BASE_FRAME::ClearUndoRedoList()
|
||||||
{
|
{
|
||||||
ClearUndoORRedoList( m_UndoList );
|
ClearUndoORRedoList( UNDO_LIST );
|
||||||
ClearUndoORRedoList( m_RedoList );
|
ClearUndoORRedoList( REDO_LIST );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_BASE_FRAME::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
|
void EDA_BASE_FRAME::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
|
||||||
{
|
{
|
||||||
m_UndoList.PushCommand( aNewitem );
|
m_undoList.PushCommand( aNewitem );
|
||||||
|
|
||||||
// Delete the extra items, if count max reached
|
// Delete the extra items, if count max reached
|
||||||
if( m_UndoRedoCountMax > 0 )
|
if( m_UndoRedoCountMax > 0 )
|
||||||
|
@ -811,14 +811,14 @@ void EDA_BASE_FRAME::PushCommandToUndoList( PICKED_ITEMS_LIST* aNewitem )
|
||||||
int extraitems = GetUndoCommandCount() - m_UndoRedoCountMax;
|
int extraitems = GetUndoCommandCount() - m_UndoRedoCountMax;
|
||||||
|
|
||||||
if( extraitems > 0 )
|
if( extraitems > 0 )
|
||||||
ClearUndoORRedoList( m_UndoList, extraitems );
|
ClearUndoORRedoList( UNDO_LIST, extraitems );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_BASE_FRAME::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
|
void EDA_BASE_FRAME::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
|
||||||
{
|
{
|
||||||
m_RedoList.PushCommand( aNewitem );
|
m_redoList.PushCommand( aNewitem );
|
||||||
|
|
||||||
// Delete the extra items, if count max reached
|
// Delete the extra items, if count max reached
|
||||||
if( m_UndoRedoCountMax > 0 )
|
if( m_UndoRedoCountMax > 0 )
|
||||||
|
@ -826,20 +826,20 @@ void EDA_BASE_FRAME::PushCommandToRedoList( PICKED_ITEMS_LIST* aNewitem )
|
||||||
int extraitems = GetRedoCommandCount() - m_UndoRedoCountMax;
|
int extraitems = GetRedoCommandCount() - m_UndoRedoCountMax;
|
||||||
|
|
||||||
if( extraitems > 0 )
|
if( extraitems > 0 )
|
||||||
ClearUndoORRedoList( m_RedoList, extraitems );
|
ClearUndoORRedoList( REDO_LIST, extraitems );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromUndoList( )
|
PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromUndoList( )
|
||||||
{
|
{
|
||||||
return m_UndoList.PopCommand();
|
return m_undoList.PopCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromRedoList( )
|
PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromRedoList( )
|
||||||
{
|
{
|
||||||
return m_RedoList.PopCommand();
|
return m_redoList.PopCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ void DIALOG_SYMBOL_REMAP::OnRemapSymbols( wxCommandEvent& aEvent )
|
||||||
if( viewer )
|
if( viewer )
|
||||||
viewer->ReCreateListLib();
|
viewer->ReCreateListLib();
|
||||||
|
|
||||||
parent->ClearUndoORRedoList( parent->m_UndoList, 1 );
|
parent->ClearUndoORRedoList( EDA_BASE_FRAME::UNDO_LIST, 1 );
|
||||||
parent->SyncView();
|
parent->SyncView();
|
||||||
parent->GetCanvas()->Refresh();
|
parent->GetCanvas()->Refresh();
|
||||||
parent->OnModify();
|
parent->OnModify();
|
||||||
|
|
|
@ -910,18 +910,20 @@ bool LIB_EDIT_FRAME::IsContentModified()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LIB_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
|
void LIB_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
|
||||||
{
|
{
|
||||||
if( aItemCount == 0 )
|
if( aItemCount == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for( auto& command : aList.m_CommandsList )
|
UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
|
||||||
|
|
||||||
|
for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
|
||||||
{
|
{
|
||||||
command->ClearListAndDeleteItems();
|
command->ClearListAndDeleteItems();
|
||||||
delete command;
|
delete command;
|
||||||
}
|
}
|
||||||
|
|
||||||
aList.m_CommandsList.clear();
|
list.m_CommandsList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -349,12 +349,12 @@ public:
|
||||||
* - data pointed by wrappers are deleted if not in use in schematic
|
* - data pointed by wrappers are deleted if not in use in schematic
|
||||||
* i.e. when they are copy of a schematic item or they are no more in use (DELETED)
|
* i.e. when they are copy of a schematic item or they are no more in use (DELETED)
|
||||||
*
|
*
|
||||||
* @param aList = the UNDO_REDO_CONTAINER to clear
|
* @param whichList = the UNDO_REDO_CONTAINER to clear
|
||||||
* @param aItemCount = the count of items to remove. < 0 for all items
|
* @param aItemCount = the count of items to remove. < 0 for all items
|
||||||
* items are removed from the beginning of the list.
|
* items are removed from the beginning of the list.
|
||||||
* So this function can be called to remove old commands
|
* So this function can be called to remove old commands
|
||||||
*/
|
*/
|
||||||
void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ) override;
|
void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -56,7 +56,7 @@ void LIB_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* ItemToCopy, UNDO_REDO_T undoT
|
||||||
PushCommandToUndoList( lastcmd );
|
PushCommandToUndoList( lastcmd );
|
||||||
|
|
||||||
// Clear redo list, because after new save there is no redo to do.
|
// Clear redo list, because after new save there is no redo to do.
|
||||||
ClearUndoORRedoList( m_RedoList );
|
ClearUndoORRedoList( REDO_LIST );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -847,12 +847,12 @@ public:
|
||||||
* - data pointed by wrappers are deleted if not in use in schematic
|
* - data pointed by wrappers are deleted if not in use in schematic
|
||||||
* i.e. when they are copy of a schematic item or they are no more in use (DELETED)
|
* i.e. when they are copy of a schematic item or they are no more in use (DELETED)
|
||||||
*
|
*
|
||||||
* @param aList = the UNDO_REDO_CONTAINER to clear
|
* @param whichList = the UNDO_REDO_CONTAINER to clear
|
||||||
* @param aItemCount = the count of items to remove. < 0 for all items
|
* @param aItemCount = the count of items to remove. < 0 for all items
|
||||||
* items are removed from the beginning of the list.
|
* items are removed from the beginning of the list.
|
||||||
* So this function can be called to remove old commands
|
* So this function can be called to remove old commands
|
||||||
*/
|
*/
|
||||||
void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ) override;
|
void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clone \a aItem and owns that clone in this container.
|
* Clone \a aItem and owns that clone in this container.
|
||||||
|
|
|
@ -146,7 +146,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_SCREEN* aScreen,
|
||||||
PushCommandToUndoList( commandToUndo );
|
PushCommandToUndoList( commandToUndo );
|
||||||
|
|
||||||
/* Clear redo list, because after new save there is no redo to do */
|
/* Clear redo list, because after new save there is no redo to do */
|
||||||
ClearUndoORRedoList( m_RedoList );
|
ClearUndoORRedoList( REDO_LIST );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -242,7 +242,7 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
||||||
PushCommandToUndoList( commandToUndo );
|
PushCommandToUndoList( commandToUndo );
|
||||||
|
|
||||||
/* Clear redo list, because after new save there is no redo to do */
|
/* Clear redo list, because after new save there is no redo to do */
|
||||||
ClearUndoORRedoList( m_RedoList );
|
ClearUndoORRedoList( REDO_LIST );
|
||||||
}
|
}
|
||||||
else // Should not occur
|
else // Should not occur
|
||||||
{
|
{
|
||||||
|
@ -369,18 +369,20 @@ void SCH_EDIT_FRAME::RollbackSchematicFromUndo()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
|
void SCH_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
|
||||||
{
|
{
|
||||||
if( aItemCount == 0 )
|
if( aItemCount == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for( auto& command : aList.m_CommandsList )
|
UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
|
||||||
|
|
||||||
|
for( PICKED_ITEMS_LIST* command : list.m_CommandsList )
|
||||||
{
|
{
|
||||||
command->ClearListAndDeleteItems();
|
command->ClearListAndDeleteItems();
|
||||||
delete command;
|
delete command;
|
||||||
}
|
}
|
||||||
|
|
||||||
aList.m_CommandsList.clear();
|
list.m_CommandsList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -152,12 +152,9 @@ protected:
|
||||||
bool m_FlagSave; // Indicates automatic file save.
|
bool m_FlagSave; // Indicates automatic file save.
|
||||||
int m_UndoRedoCountMax; // undo/Redo command Max depth
|
int m_UndoRedoCountMax; // undo/Redo command Max depth
|
||||||
|
|
||||||
public:
|
UNDO_REDO_CONTAINER m_undoList; // Objects list for the undo command (old data)
|
||||||
// Undo/redo list of commands
|
UNDO_REDO_CONTAINER m_redoList; // Objects list for the redo command (old data)
|
||||||
UNDO_REDO_CONTAINER m_UndoList; // Objects list for the undo command (old data)
|
|
||||||
UNDO_REDO_CONTAINER m_RedoList; // Objects list for the redo command (old data)
|
|
||||||
|
|
||||||
protected:
|
|
||||||
wxString m_mruPath; // Most recently used path.
|
wxString m_mruPath; // Most recently used path.
|
||||||
|
|
||||||
EDA_UNITS m_userUnits;
|
EDA_UNITS m_userUnits;
|
||||||
|
@ -551,7 +548,8 @@ public:
|
||||||
* old commands this will empty the list of commands.
|
* old commands this will empty the list of commands.
|
||||||
* Commands are deleted from the older to the last.
|
* Commands are deleted from the older to the last.
|
||||||
*/
|
*/
|
||||||
virtual void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 )
|
enum UNDO_REDO_LIST { UNDO_LIST, REDO_LIST };
|
||||||
|
virtual void ClearUndoORRedoList( UNDO_REDO_LIST aList, int aItemCount = -1 )
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -592,28 +590,10 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual PICKED_ITEMS_LIST* PopCommandFromRedoList();
|
virtual PICKED_ITEMS_LIST* PopCommandFromRedoList();
|
||||||
|
|
||||||
int GetUndoCommandCount() const
|
int GetUndoCommandCount() const { return m_undoList.m_CommandsList.size(); }
|
||||||
{
|
int GetRedoCommandCount() const { return m_redoList.m_CommandsList.size(); }
|
||||||
return m_UndoList.m_CommandsList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetRedoCommandCount() const
|
|
||||||
{
|
|
||||||
return m_RedoList.m_CommandsList.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetMaxUndoItems() const { return m_UndoRedoCountMax; }
|
int GetMaxUndoItems() const { return m_UndoRedoCountMax; }
|
||||||
|
|
||||||
void SetMaxUndoItems( int aMax )
|
|
||||||
{
|
|
||||||
if( aMax >= 0 && aMax < ABS_MAX_UNDO_ITEMS )
|
|
||||||
m_UndoRedoCountMax = aMax;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxFAIL_MSG( "Maximum undo items not within limits" );
|
|
||||||
m_UndoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -833,23 +833,24 @@ void PL_EDITOR_FRAME::OnNewPageLayout()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PL_EDITOR_FRAME::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
|
void PL_EDITOR_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
|
||||||
{
|
{
|
||||||
if( aItemCount == 0 )
|
if( aItemCount == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unsigned icnt = aList.m_CommandsList.size();
|
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;
|
icnt = aItemCount;
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < icnt; ii++ )
|
for( unsigned ii = 0; ii < icnt; ii++ )
|
||||||
{
|
{
|
||||||
if( aList.m_CommandsList.size() == 0 )
|
if( list.m_CommandsList.size() == 0 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
|
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
||||||
aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
|
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
||||||
|
|
||||||
curr_cmd->ClearListAndDeleteItems();
|
curr_cmd->ClearListAndDeleteItems();
|
||||||
delete curr_cmd; // Delete command
|
delete curr_cmd; // Delete command
|
||||||
|
|
|
@ -285,7 +285,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Function ClearUndoORRedoList
|
* Function ClearUndoORRedoList
|
||||||
*/
|
*/
|
||||||
void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ) override;
|
void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool saveCurrentPageLayout();
|
bool saveCurrentPageLayout();
|
||||||
|
|
|
@ -42,7 +42,7 @@ void PL_EDITOR_FRAME::SaveCopyInUndoList()
|
||||||
PushCommandToUndoList( lastcmd );
|
PushCommandToUndoList( lastcmd );
|
||||||
|
|
||||||
// Clear redo list, because after new save there is no redo to do.
|
// Clear redo list, because after new save there is no redo to do.
|
||||||
ClearUndoORRedoList( m_RedoList );
|
ClearUndoORRedoList( REDO_LIST );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -198,12 +198,12 @@ public:
|
||||||
* datas pointed by wrappers are deleted if not in use in schematic
|
* datas pointed by wrappers are deleted if not in use in schematic
|
||||||
* i.e. when they are copy of a schematic item or they are no more in use
|
* i.e. when they are copy of a schematic item or they are no more in use
|
||||||
* (DELETED)
|
* (DELETED)
|
||||||
* @param aList = the UNDO_REDO_CONTAINER to clear
|
* @param whichList = the UNDO_REDO_CONTAINER to clear
|
||||||
* @param aItemCount = the count of items to remove. < 0 for all items
|
* @param aItemCount = the count of items to remove. < 0 for all items
|
||||||
* items are removed from the beginning of the list.
|
* items are removed from the beginning of the list.
|
||||||
* So this function can be called to remove old commands
|
* So this function can be called to remove old commands
|
||||||
*/
|
*/
|
||||||
void ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount = -1 ) override;
|
void ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount = -1 ) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// User defined rotation angle (in tenths of a degree).
|
/// User defined rotation angle (in tenths of a degree).
|
||||||
|
|
|
@ -318,7 +318,7 @@ void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsLis
|
||||||
PushCommandToUndoList( commandToUndo );
|
PushCommandToUndoList( commandToUndo );
|
||||||
|
|
||||||
/* Clear redo list, because after a new command one cannot redo a command */
|
/* Clear redo list, because after a new command one cannot redo a command */
|
||||||
ClearUndoORRedoList( m_RedoList );
|
ClearUndoORRedoList( REDO_LIST );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -585,23 +585,24 @@ void PCB_BASE_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void PCB_BASE_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_CONTAINER& aList, int aItemCount )
|
void PCB_BASE_EDIT_FRAME::ClearUndoORRedoList( UNDO_REDO_LIST whichList, int aItemCount )
|
||||||
{
|
{
|
||||||
if( aItemCount == 0 )
|
if( aItemCount == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unsigned icnt = aList.m_CommandsList.size();
|
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;
|
icnt = aItemCount;
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < icnt; ii++ )
|
for( unsigned ii = 0; ii < icnt; ii++ )
|
||||||
{
|
{
|
||||||
if( aList.m_CommandsList.size() == 0 )
|
if( list.m_CommandsList.size() == 0 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* curr_cmd = aList.m_CommandsList[0];
|
PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
|
||||||
aList.m_CommandsList.erase( aList.m_CommandsList.begin() );
|
list.m_CommandsList.erase( list.m_CommandsList.begin() );
|
||||||
|
|
||||||
curr_cmd->ClearListAndDeleteItems();
|
curr_cmd->ClearListAndDeleteItems();
|
||||||
delete curr_cmd; // Delete command
|
delete curr_cmd; // Delete command
|
||||||
|
|
Loading…
Reference in New Issue