From 25bd4b40824c7df4344337256f7a4691e4f219c7 Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 6 Jun 2019 11:47:30 +0300 Subject: [PATCH] Allow nested transactions have any number of attached transactions (needed for filters Selection feature restart in Groups any time in new nested transaction). --- src/Model/Model_Session.cpp | 13 +++++++------ src/Model/Model_Session.h | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index b07ca70d4..5a8f6f736 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -80,7 +80,7 @@ void Model_Session::closeAll() void Model_Session::startOperation(const std::string& theId, const bool theAttachedToNested) { - myOperationAttachedToNext = theAttachedToNested; + myOperationAttachedToNext.push_back(theAttachedToNested); ROOT_DOC->startOperation(); ROOT_DOC->operationId(theId); static std::shared_ptr aStartedMsg @@ -98,10 +98,11 @@ void Model_Session::finishOperation() { setCheckTransactions(false); ROOT_DOC->finishOperation(); - if (myOperationAttachedToNext) { // twice, with nested + while(myOperationAttachedToNext.back()) { // with nested, the first transaction can not be attached ROOT_DOC->finishOperation(); - myOperationAttachedToNext = false; + myOperationAttachedToNext.pop_back(); } + myOperationAttachedToNext.pop_back(); setCheckTransactions(true); } @@ -109,10 +110,11 @@ void Model_Session::abortOperation() { setCheckTransactions(false); ROOT_DOC->abortOperation(); - if (myOperationAttachedToNext) { // twice, with nested + while(myOperationAttachedToNext.back()) { // with nested, the first transaction can not be attached ROOT_DOC->abortOperation(); - myOperationAttachedToNext = false; + myOperationAttachedToNext.pop_back(); } + myOperationAttachedToNext.pop_back(); setCheckTransactions(true); // here the update mechanism may work after abort, so, suppress the warnings about // modifications outside of the transactions @@ -427,7 +429,6 @@ Model_Session::Model_Session() { myPluginsInfoLoaded = false; myCheckTransactions = true; - myOperationAttachedToNext = false; ModelAPI_Session::setSession(std::shared_ptr(this)); // register the configuration reading listener Events_Loop* aLoop = Events_Loop::loop(); diff --git a/src/Model/Model_Session.h b/src/Model/Model_Session.h index 9b3da71a8..c54d89229 100644 --- a/src/Model/Model_Session.h +++ b/src/Model/Model_Session.h @@ -48,7 +48,8 @@ class Model_Session : public ModelAPI_Session, public Events_Listener /// if true, generates error if document is updated outside of transaction bool myCheckTransactions; - bool myOperationAttachedToNext; ///< the current operation must be committed twice, with nested + ///< if true, the current operation must be committed twice, with nested (list for any nesting depth) + std::list myOperationAttachedToNext; public: //! Loads the OCAF document from the file. -- 2.39.2