From: mpv Date: Wed, 24 Dec 2014 07:24:00 +0000 (+0300) Subject: Fix of the problem that on undo/redo of new part creation it becomes inactive and... X-Git-Tag: V_0.7.0_rc1~52 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6e79311a44ef9acbcfc3ab2f6f9d529eaf329e76;p=modules%2Fshaper.git Fix of the problem that on undo/redo of new part creation it becomes inactive and tried to be saved by copying the file. --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 1e38773f0..60f163499 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -205,32 +205,29 @@ bool Model_Document::save(const char* theFileName, std::list& theRe myTransactionSave = myTransactionsCounter; if (isDone) { // save also sub-documents if any theResults.push_back(TCollection_AsciiString(aPath).ToCString()); - const std::set aSubs = subDocuments(true); + const std::set aSubs = subDocuments(false); std::set::iterator aSubIter = aSubs.begin(); for (; aSubIter != aSubs.end() && isDone; aSubIter++) { - isDone = subDoc(*aSubIter)->save(theFileName, theResults); - } - const std::set allSubs = subDocuments(false); - if (isDone) { // also try to copy the not-activated sub-documents - for(aSubIter = allSubs.begin(); aSubIter != allSubs.end(); aSubIter++) { - if (aSubs.find(*aSubIter) == aSubs.end()) { // filter out the active subs - std::string aDocName = *aSubIter; - if (!aDocName.empty() && aSubs.find(aDocName) == aSubs.end()) { - // just copy file - TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName)); - OSD_Path aPath(aSubPath); - OSD_File aFile(aPath); - if (aFile.Exists()) { - TCollection_AsciiString aDestinationDir(DocFileName(theFileName, aDocName)); - OSD_Path aDestination(aDestinationDir); - aFile.Copy(aDestination); - theResults.push_back(aDestinationDir.ToCString()); - } else { - Events_Error::send( - std::string("Can not open file ") + aSubPath.ToCString() + " for saving"); - } + if (anApp->isLoadByDemand(*aSubIter)) { + // copy not-activated document that is not in the memory + std::string aDocName = *aSubIter; + if (!aDocName.empty()) { + // just copy file + TCollection_AsciiString aSubPath(DocFileName(anApp->loadPath().c_str(), aDocName)); + OSD_Path aPath(aSubPath); + OSD_File aFile(aPath); + if (aFile.Exists()) { + TCollection_AsciiString aDestinationDir(DocFileName(theFileName, aDocName)); + OSD_Path aDestination(aDestinationDir); + aFile.Copy(aDestination); + theResults.push_back(aDestinationDir.ToCString()); + } else { + Events_Error::send( + std::string("Can not open file ") + aSubPath.ToCString() + " for saving"); } } + } else { // simply save opened document + isDone = subDoc(*aSubIter)->save(theFileName, theResults); } } }