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_5_0a1~167^2~32 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e0368a13bfb6b24891ba9d31f0f958e117fe21ea;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(); }