From fc787375f074af74e17464b400cc59797590e52b Mon Sep 17 00:00:00 2001 From: mpv Date: Thu, 17 Sep 2015 09:47:36 +0300 Subject: [PATCH] Partial fix for the issue #992: synchronisation of transaction in that case. The problem with data model in OB will be fixed with persistence mechanism of the current Active part and history line will be implemented. --- src/Model/Model_Document.cpp | 20 ++++++++++++++++++++ src/Model/Model_Document.h | 6 ++++++ src/Model/Model_ResultPart.cpp | 1 + src/ModelAPI/ModelAPI_Document.h | 5 +++++ src/XGUI/XGUI_DataModel.cpp | 2 +- 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index d85fb7b29..fb8b0a1de 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -1000,6 +1000,26 @@ std::shared_ptr Model_Document::internalFeature(const int theI return myObjs->internalFeature(theIndex); } +void Model_Document::synchronizeTransactions() +{ + Model_Document* aRoot = + std::dynamic_pointer_cast(ModelAPI_Session::get()->moduleDocument()).get(); + if (aRoot == this) + return; // don't need to synchronise root with root + + std::shared_ptr aSession = + std::dynamic_pointer_cast(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: diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index d82b853f6..ad28e74d4 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -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 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 createConstruction( diff --git a/src/Model/Model_ResultPart.cpp b/src/Model/Model_ResultPart.cpp index c01d714f4..7ce87b434 100644 --- a/src/Model/Model_ResultPart.cpp +++ b/src/Model/Model_ResultPart.cpp @@ -69,6 +69,7 @@ void Model_ResultPart::activate() std::shared_ptr aDoc = document()->subDocument(data()->name()); myIsInLoad = false; if (aDoc) { + aDoc->synchronizeTransactions(); aDocRef->setValue(aDoc); } } diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 6274305ca..03a740af2 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -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 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 diff --git a/src/XGUI/XGUI_DataModel.cpp b/src/XGUI/XGUI_DataModel.cpp index 47191c887..704fd0738 100644 --- a/src/XGUI/XGUI_DataModel.cpp +++ b/src/XGUI/XGUI_DataModel.cpp @@ -88,7 +88,7 @@ void XGUI_DataModel::processEvent(const std::shared_ptr& 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; -- 2.39.2