From: azv Date: Thu, 17 Oct 2019 09:42:23 +0000 (+0300) Subject: Issue #3044: Undo list contains empty string for Load python script X-Git-Tag: V9_4_0rc1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=90a5c5bd90e41e931f08b64ccbf06cfa376267e1;p=modules%2Fshaper.git Issue #3044: Undo list contains empty string for Load python script Improve indexation (do not take into account the empty transactions). --- diff --git a/src/ModelHighAPI/ModelHighAPI_Services.cpp b/src/ModelHighAPI/ModelHighAPI_Services.cpp index 98f7aff84..4bcd182fd 100644 --- a/src/ModelHighAPI/ModelHighAPI_Services.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Services.cpp @@ -98,9 +98,16 @@ std::shared_ptr 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(); }