From 385abcce9d69c0308c27973925f26fb42ed9a58e Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 16 Oct 2019 11:55:08 +0300 Subject: [PATCH] Issue #3044: Undo list contains empty string for Load python script * Set name for each transaction as "Operation_N" * Improve dumping to Python to avoid odd call of "model.do()" right before "model.end()" which cause an additional empty transaction. --- src/ModelHighAPI/ModelHighAPI_Dumper.cpp | 14 ++++++++++---- src/ModelHighAPI/ModelHighAPI_Dumper.h | 3 ++- src/ModelHighAPI/ModelHighAPI_Services.cpp | 8 ++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp index 836f33c93..9df987e61 100644 --- a/src/ModelHighAPI/ModelHighAPI_Dumper.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Dumper.cpp @@ -663,8 +663,12 @@ bool ModelHighAPI_Dumper::process(const std::shared_ptr& theD // dump all other features for (anObjIt = anObjects.begin(); anObjIt != anObjects.end(); ++anObjIt) { CompositeFeaturePtr aCompFeat = std::dynamic_pointer_cast(*anObjIt); - if (aCompFeat) // iteratively process composite features - isOk = process(aCompFeat) && isOk; + if (aCompFeat) { + // iteratively process composite features, + // if the composite feature is the last in the document, no need to dump "model.do()" action + std::list::const_iterator aNext = anObjIt; + isOk = process(aCompFeat, false, ++aNext != anObjects.end()) && isOk; + } else if (!isDumped(EntityPtr(*anObjIt))) { // dump folder FolderPtr aFolder = std::dynamic_pointer_cast(*anObjIt); @@ -683,7 +687,7 @@ bool ModelHighAPI_Dumper::process(const std::shared_ptr& theD } bool ModelHighAPI_Dumper::process(const std::shared_ptr& theComposite, - bool isForce) + bool isForce, bool isDumpModelDo) { // increase composite features stack ++gCompositeStackDepth; @@ -716,7 +720,9 @@ bool ModelHighAPI_Dumper::process(const std::shared_ptr& theComposite, - bool isForce = false); + bool isForce = false, + bool isDumpModelDo = true); /// Iterate all features in composite feature and dump them into intermediate buffer /// \param theComposite [in] parent composite feature diff --git a/src/ModelHighAPI/ModelHighAPI_Services.cpp b/src/ModelHighAPI/ModelHighAPI_Services.cpp index c9be66129..98f7aff84 100644 --- a/src/ModelHighAPI/ModelHighAPI_Services.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Services.cpp @@ -27,6 +27,7 @@ #include #include +#include //-------------------------------------------------------------------------------------- std::shared_ptr moduleDocument() @@ -97,7 +98,10 @@ std::shared_ptr standardPlane(const std::string & theName){ //-------------------------------------------------------------------------------------- void begin() { - ModelAPI_Session::get()->startOperation(); + static int aTransactionID = 0; + std::ostringstream aTransactionName; + aTransactionName << "Operation_" << ++aTransactionID; + ModelAPI_Session::get()->startOperation(aTransactionName.str()); } void end() @@ -119,7 +123,7 @@ void apply() { auto aSession = ModelAPI_Session::get(); aSession->finishOperation(); - aSession->startOperation(); + begin(); } void updateFeatures() -- 2.30.2