COMMIT class: removed m_committed flag, added clear() and Empty() methods.

This commit is contained in:
Maciej Suminski 2016-06-15 10:15:10 +02:00
parent b815ea7865
commit 940765f4b3
2 changed files with 15 additions and 9 deletions

View File

@ -27,19 +27,15 @@
COMMIT::COMMIT()
{
m_committed = false;
}
COMMIT::~COMMIT()
{
if( !m_committed )
for( COMMIT_LINE& ent : m_changes )
{
for( COMMIT_LINE& ent : m_changes )
{
if( ent.m_copy )
delete ent.m_copy;
}
if( ent.m_copy )
delete ent.m_copy;
}
}

View File

@ -89,6 +89,11 @@ public:
///> Revertes the commit by restoring the modifed items state.
virtual void Revert() = 0;
bool Empty() const
{
return m_changes.empty();
}
protected:
struct COMMIT_LINE
{
@ -97,14 +102,19 @@ protected:
CHANGE_TYPE m_type;
};
// Should be called in Push() & Revert() methods
void clear()
{
m_changedItems.clear();
m_changes.clear();
}
virtual void makeEntry( EDA_ITEM* aItem, CHANGE_TYPE aType, EDA_ITEM* aCopy = NULL );
virtual EDA_ITEM* parentObject( EDA_ITEM* aItem ) const = 0;
CHANGE_TYPE convert( UNDO_REDO_T aType ) const;
bool m_committed;
std::set<EDA_ITEM*> m_changedItems;
std::vector<COMMIT_LINE> m_changes;
};