From: azv Date: Thu, 17 Oct 2019 06:49:01 +0000 (+0300) Subject: Issue #3044: Undo list contains empty string for Load python script X-Git-Tag: V9_4_0b1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5410a9ff93849a9c365d69a0dd8ae19747d0531f;p=modules%2Fshaper.git Issue #3044: Undo list contains empty string for Load python script Clear the Undo list when Python script is loaded. --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index be2877848..7bf6290be 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -852,6 +852,13 @@ bool Model_Document::isModified() return myTransactions.size() != myTransactionSave || isOperation(); } +void Model_Document::clearUndos() +{ + myDoc->ClearUndos(); + myTransactions.clear(); + myRedos.clear(); +} + bool Model_Document::canUndo() { // issue 406 : if transaction is opened, but nothing to undo behind, can not undo diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 72a570738..457a8717b 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -85,6 +85,8 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual bool canUndo(); //! Undoes last operation MODEL_EXPORT virtual void undo(); + //! Clean the undo list + MODEL_EXPORT virtual void clearUndos(); //! Returns True if there are available Redo-s MODEL_EXPORT virtual bool canRedo(); //! Redoes last operation diff --git a/src/Model/Model_Session.cpp b/src/Model/Model_Session.cpp index 89f90ee4a..4ccc8f1b7 100644 --- a/src/Model/Model_Session.cpp +++ b/src/Model/Model_Session.cpp @@ -143,6 +143,11 @@ bool Model_Session::isModified() return ROOT_DOC->isModified(); } +void Model_Session::clearUndos() +{ + ROOT_DOC->clearUndos(); +} + bool Model_Session::canUndo() { return ROOT_DOC->canUndo(); diff --git a/src/Model/Model_Session.h b/src/Model/Model_Session.h index b480a67e9..2ffc8d1bb 100644 --- a/src/Model/Model_Session.h +++ b/src/Model/Model_Session.h @@ -87,6 +87,8 @@ class Model_Session : public ModelAPI_Session, public Events_Listener MODEL_EXPORT virtual bool canUndo(); //! Undoes last operation MODEL_EXPORT virtual void undo(); + //! Clean the undo list + MODEL_EXPORT virtual void clearUndos(); //! Returns True if there are available Redos MODEL_EXPORT virtual bool canRedo(); //! Redoes last operation diff --git a/src/ModelAPI/ModelAPI_Session.h b/src/ModelAPI/ModelAPI_Session.h index 84a925aa2..8955bcb03 100644 --- a/src/ModelAPI/ModelAPI_Session.h +++ b/src/ModelAPI/ModelAPI_Session.h @@ -78,6 +78,8 @@ class MODELAPI_EXPORT ModelAPI_Session virtual bool canUndo() = 0; //! Undoes last operation virtual void undo() = 0; + //! Clean the undo list + virtual void clearUndos() = 0; //! Returns True if there are available Redos virtual bool canRedo() = 0; //! Redoes last operation diff --git a/src/ModelHighAPI/ModelHighAPI_Services.cpp b/src/ModelHighAPI/ModelHighAPI_Services.cpp index 98f7aff84..21ab68248 100644 --- a/src/ModelHighAPI/ModelHighAPI_Services.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Services.cpp @@ -116,6 +116,8 @@ void end() } ModelAPI_Session::get()->finishOperation(); + // issue #3044: clear undo/redo lists + ModelAPI_Session::get()->clearUndos(); // to update data tree in the end of dumped script execution ModelAPI_EventCreator::get()->sendReordered(FeaturePtr()); }