Salome HOME
Allow nested transactions have any number of attached transactions (needed for filter...
[modules/shaper.git] / src / Model / Model_Session.cpp
index b07ca70d4de891b0672757bc5f86c86981a4fcb4..5a8f6f736f9b8c6ae4725d05039ac4198bfa46af 100644 (file)
@@ -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<Events_Message> 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<ModelAPI_Session>(this));
   // register the configuration reading listener
   Events_Loop* aLoop = Events_Loop::loop();