]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/Model/Model_Session.cpp
Salome HOME
Fix crashes in unit tests (produced by stack of transactions)
[modules/shaper.git] / src / Model / Model_Session.cpp
index afdf7e4a5773f37da44c341b869d1ad2b54344b6..aed8b486a860344541266fa8cb085bff37487bf0 100644 (file)
@@ -98,12 +98,14 @@ void Model_Session::finishOperation()
 {
   setCheckTransactions(false);
   ROOT_DOC->finishOperation();
-  while(myOperationAttachedToNext.back()) {
-    // with nested, the first transaction can not be attached
-    ROOT_DOC->finishOperation();
+  if (!myOperationAttachedToNext.empty()) {
+    while (myOperationAttachedToNext.back()) {
+      // with nested, the first transaction can not be attached
+      ROOT_DOC->finishOperation();
+      myOperationAttachedToNext.pop_back();
+    }
     myOperationAttachedToNext.pop_back();
   }
-  myOperationAttachedToNext.pop_back();
   setCheckTransactions(true);
 }
 
@@ -111,12 +113,14 @@ void Model_Session::abortOperation()
 {
   setCheckTransactions(false);
   ROOT_DOC->abortOperation();
-  while(myOperationAttachedToNext.back()) {
-    // with nested, the first transaction can not be attached
-    ROOT_DOC->abortOperation();
+  if (!myOperationAttachedToNext.empty()) {
+    while (myOperationAttachedToNext.back()) {
+      // with nested, the first transaction can not be attached
+      ROOT_DOC->abortOperation();
+      myOperationAttachedToNext.pop_back();
+    }
     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