Salome HOME
Issue #3044: Undo list contains empty string for Load python script
authorazv <azv@opencascade.com>
Thu, 17 Oct 2019 06:49:01 +0000 (09:49 +0300)
committerazv <azv@opencascade.com>
Thu, 17 Oct 2019 06:49:01 +0000 (09:49 +0300)
Clear the Undo list when Python script is loaded.

src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Session.cpp
src/Model/Model_Session.h
src/ModelAPI/ModelAPI_Session.h
src/ModelHighAPI/ModelHighAPI_Services.cpp

index be2877848b1a34b891a39b3dae19561fb94e780a..7bf6290bef03159e15f2d475de583beb4bee8ae4 100644 (file)
@@ -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
index 72a570738b5080a167838dc2fa0830d3f43eeebf..457a8717b79ea5060b243e14d77440e5608e1d9e 100644 (file)
@@ -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
index 89f90ee4aff07fa7f3799e7dc193dab01b471437..4ccc8f1b748e2dc99faacb3563819636f067ebaf 100644 (file)
@@ -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();
index b480a67e951c03cfd5eca6104bb3c9f7eb182f4b..2ffc8d1bb0bd5046b1d3ae5430eafc824419b456 100644 (file)
@@ -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
index 84a925aa2074672160275cbdc948ff6a92039d51..8955bcb031fa800b68b75a3ea856266e4e0d7936 100644 (file)
@@ -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
index 98f7aff84a47776b899e98ace3ca43a7e521f335..21ab682485a7924b0b5d09a8cc1249e6ba4eb2c1 100644 (file)
@@ -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());
 }