From: mpv Date: Thu, 30 Mar 2017 11:52:00 +0000 (+0300) Subject: Fix for the issue #2009: always save with history line moved to the end. X-Git-Tag: V_2.7.0~125 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b5570e71cedf41bf018677ba3813280dab131fb1;p=modules%2Fshaper.git Fix for the issue #2009: always save with history line moved to the end. --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 9ff99fbad..ca4c907b0 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -235,6 +235,17 @@ bool Model_Document::load(const char* theDirName, const char* theFileName, Docum bool Model_Document::save( const char* theDirName, const char* theFileName, std::list& theResults) { + // if the history line is not in the end, move it to the end before save, otherwise + // problems with results restore and (the most important) naming problems will appear + // due to change evolution to SELECTION (problems in NamedShape and Name) + FeaturePtr aWasCurrent; + std::shared_ptr aSession = + std::dynamic_pointer_cast(Model_Session::get()); + if (currentFeature(false) != lastFeature()) { + aSession->setCheckTransactions(false); + aWasCurrent = currentFeature(false); + setCurrentFeature(lastFeature(), false); + } // create a directory in the root document if it is not yet exist Handle(Model_Application) anApp = Model_Application::getApplication(); if (isRoot()) { @@ -253,6 +264,10 @@ bool Model_Document::save( Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Events_InfoMessage("Model_Document", "Exception in saving of document: %1").arg(aFail->GetMessageString()).send(); + if (aWasCurrent.get()) { // return the current feature to the initial position + setCurrentFeature(aWasCurrent, false); + aSession->setCheckTransactions(true); + } return false; } bool isDone = aStatus == PCDM_SS_OK || aStatus == PCDM_SS_No_Obj; @@ -271,6 +286,12 @@ bool Model_Document::save( break; } } + + if (aWasCurrent.get()) { // return the current feature to the initial position + setCurrentFeature(aWasCurrent, false); + aSession->setCheckTransactions(true); + } + myTransactionSave = int(myTransactions.size()); if (isDone) { // save also sub-documents if any theResults.push_back(TCollection_AsciiString(aPath).ToCString());