From f37788c806a371d84963c1fd72e1a2050258372b Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 22 Jan 2015 17:11:09 +0300 Subject: [PATCH] Fix for Issue #375: abort of nested operation problem --- src/Model/Model_Document.cpp | 23 +++++++++++++++-------- src/Model/Model_Document.h | 3 +++ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index fb6ebf8e4..f1f10b103 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -370,7 +370,7 @@ void Model_Document::abortOperation() { if (!myNestedNum.empty() && !myDoc->HasOpenCommand()) { // abort all what was done in nested compactNested(); - undo(); + undoInternal(false); myDoc->ClearRedos(); myRedos.clear(); } else { // abort the current @@ -418,7 +418,7 @@ bool Model_Document::canUndo() return false; } -void Model_Document::undo() +void Model_Document::undoInternal(const bool theWithSubs) { int aNumTransactions = *myTransactions.rbegin(); myTransactions.pop_back(); @@ -429,12 +429,19 @@ void Model_Document::undo() for(int a = 0; a < aNumTransactions; a++) myDoc->Undo(); - synchronizeFeatures(true, true); - // undo for all subs - const std::set aSubs = subDocuments(true); - std::set::iterator aSubIter = aSubs.begin(); - for (; aSubIter != aSubs.end(); aSubIter++) - subDoc(*aSubIter)->undo(); + if (theWithSubs) { + synchronizeFeatures(true, true); + // undo for all subs + const std::set aSubs = subDocuments(true); + std::set::iterator aSubIter = aSubs.begin(); + for (; aSubIter != aSubs.end(); aSubIter++) + subDoc(*aSubIter)->undo(); + } +} + +void Model_Document::undo() +{ + undoInternal(true); } bool Model_Document::canRedo() diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 2c9dd2123..56490a15c 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -189,6 +189,9 @@ class Model_Document : public ModelAPI_Document //! Returns all sub documents const std::set subDocuments(const bool theActivatedOnly) const; + //! The implementation of undo: with or without recoursive calls in the sub-documents + void undoInternal(const bool theWithSubs); + friend class Model_Application; friend class Model_Session; friend class Model_Update; -- 2.39.2