From 940765f4b3ee870e96ee018c19a22b7c9780efc0 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Wed, 15 Jun 2016 10:15:10 +0200 Subject: [PATCH] COMMIT class: removed m_committed flag, added clear() and Empty() methods. --- common/commit.cpp | 10 +++------- common/commit.h | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/common/commit.cpp b/common/commit.cpp index 689d852e10..22c053e43b 100644 --- a/common/commit.cpp +++ b/common/commit.cpp @@ -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; } } diff --git a/common/commit.h b/common/commit.h index 9743b3dd03..e88e99299e 100644 --- a/common/commit.h +++ b/common/commit.h @@ -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 m_changedItems; std::vector m_changes; };