]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Allow nested transactions have any number of attached transactions (needed for filter...
authormpv <mpv@opencascade.com>
Thu, 6 Jun 2019 08:47:30 +0000 (11:47 +0300)
committermpv <mpv@opencascade.com>
Thu, 6 Jun 2019 08:47:30 +0000 (11:47 +0300)
src/Model/Model_Session.cpp
src/Model/Model_Session.h

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();
index 9b3da71a89b9e2d77d0a3f989e3c80926c0c5d74..c54d89229ff42105a8808d23105f0955fc26579e 100644 (file)
@@ -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<bool> myOperationAttachedToNext;
  public:
 
   //! Loads the OCAF document from the file.