Salome HOME
Partial fix for the issue #992: synchronisation of transaction in that case. The...
authormpv <mpv@opencascade.com>
Thu, 17 Sep 2015 06:47:36 +0000 (09:47 +0300)
committermpv <mpv@opencascade.com>
Thu, 17 Sep 2015 06:47:36 +0000 (09:47 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_ResultPart.cpp
src/ModelAPI/ModelAPI_Document.h
src/XGUI/XGUI_DataModel.cpp

index d85fb7b292b9abcbdddf464d43ece287587726ac..fb8b0a1def9dc1e7c45fd2764f14d11f8a583bb0 100644 (file)
@@ -1000,6 +1000,26 @@ std::shared_ptr<ModelAPI_Feature> Model_Document::internalFeature(const int theI
   return myObjs->internalFeature(theIndex);
 }
 
+void Model_Document::synchronizeTransactions()
+{
+  Model_Document* aRoot = 
+    std::dynamic_pointer_cast<Model_Document>(ModelAPI_Session::get()->moduleDocument()).get();
+  if (aRoot == this)
+    return; // don't need to synchronise root with root
+
+  std::shared_ptr<Model_Session> aSession = 
+    std::dynamic_pointer_cast<Model_Session>(Model_Session::get());
+  while(myRedos.size() > aRoot->myRedos.size()) { // remove redos in this
+    aSession->setCheckTransactions(false);
+    redo();
+    aSession->setCheckTransactions(true);
+  }
+  /* this case can not be reproduced in any known case for the current moment, so, just comment
+  while(myRedos.size() < aRoot->myRedos.size()) { // add more redos in this
+    undoInternal(false, true);
+  }*/
+}
+
 // Feature that is used for selection in the Part document by the external request
 class Model_SelectionInPartFeature : public ModelAPI_Feature {
 public:
index d82b853f65131b7c4bdb7a7c2a338e6fd50deb81..ad28e74d493d842dc7601f8e49f7fd625acdaa6e 100644 (file)
@@ -144,6 +144,12 @@ class Model_Document : public ModelAPI_Document
   MODEL_EXPORT virtual int numInternalFeatures();
   //! Returns the feature by zero-based index: features in the history or not
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Feature> internalFeature(const int theIndex);
+  //! Performs synchronization of transactions with the module document:
+  //! If some document is not active (by undo of activation) but in memory,
+  //! on activation the transactions must be synchronised because all redos performed 
+  //! wihtout this participation
+  MODEL_EXPORT virtual void synchronizeTransactions();
+
 
   /// Creates a construction cresults
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultConstruction> createConstruction(
index c01d714f4e4ac5e4048e64b87c47fc31ad71151a..7ce87b434be98d602a06a048d5bb9bd2e393edbe 100644 (file)
@@ -69,6 +69,7 @@ void Model_ResultPart::activate()
     std::shared_ptr<ModelAPI_Document> aDoc = document()->subDocument(data()->name());
     myIsInLoad = false;
     if (aDoc) {
+      aDoc->synchronizeTransactions();
       aDocRef->setValue(aDoc);
     }
   }
index 6274305cac47ec7f679f84a0670c20bda2decac3..03a740af211265caa0a25720a16073009b5018a0 100644 (file)
@@ -112,6 +112,11 @@ public:
   virtual int numInternalFeatures() = 0;
   //! Returns the feature by zero-based index: features in the history or not
   virtual std::shared_ptr<ModelAPI_Feature> internalFeature(const int theIndex) = 0;
+  //! Performs synchronization of transactions with the module document:
+  //! If some document is not active (by undo of activation) but in memory,
+  //! on activation the transactions must be synchronised because all redos performed 
+  //! wihtout this participation
+  virtual void synchronizeTransactions() = 0;
 
 
   //! To virtually destroy the fields of successors
index 47191c887ed5ccc3e1179aa64ec66ee042a0e934..704fd0738e75187c4a49f7ef50e1c35d4eb8747f 100644 (file)
@@ -88,7 +88,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr<Events_Message>& theMess
     std::string aObjType;
     for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
       ObjectPtr aObject = (*aIt);
-      // We do not show objects which not has to be shown in object browser
+      // We do not show objects which does not need to be shown in object browser
       if (!aObject->isInHistory())
         continue;