]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3044: Undo list contains empty string for Load python script
authorazv <azv@opencascade.com>
Thu, 17 Oct 2019 09:42:23 +0000 (12:42 +0300)
committerazv <azv@opencascade.com>
Thu, 17 Oct 2019 09:42:23 +0000 (12:42 +0300)
Improve indexation (do not take into account the empty transactions).

src/ModelHighAPI/ModelHighAPI_Services.cpp

index 98f7aff84a47776b899e98ace3ca43a7e521f335..4bcd182fd39aba1b627f090220c47713cd857ac0 100644 (file)
@@ -98,9 +98,16 @@ std::shared_ptr<ModelAPI_Result> standardPlane(const std::string & theName){
 //--------------------------------------------------------------------------------------
 void begin()
 {
-  static int aTransactionID = 0;
+  static size_t aTransactionID = 0;
+  static size_t aNbTransactions = -1;
+  size_t aNbUndo = ModelAPI_Session::get()->undoList().size();
+  if (aNbUndo != aNbTransactions) {
+    // the last transaction was not empty, thus increase the ID
+    aNbTransactions = aNbUndo;
+    ++aTransactionID;
+  }
   std::ostringstream aTransactionName;
-  aTransactionName << "Operation_" << ++aTransactionID;
+  aTransactionName << "Operation_" << aTransactionID;
   ModelAPI_Session::get()->startOperation(aTransactionName.str());
 }
 
@@ -123,6 +130,7 @@ void apply()
 {
   auto aSession = ModelAPI_Session::get();
   aSession->finishOperation();
+  // start the next operation
   begin();
 }