From: azv Date: Wed, 16 Oct 2019 08:55:08 +0000 (+0300) Subject: Issue #3044: Undo list contains empty string for Load python script X-Git-Tag: V9_4_0b1~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=385abcce9d69c0308c27973925f26fb42ed9a58e;p=modules%2Fshaper.git 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. --- 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()