]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix of the problem that on undo/redo of new part creation it becomes inactive and...
authormpv <mikhail.ponikarov@opencascade.com>
Wed, 24 Dec 2014 07:24:00 +0000 (10:24 +0300)
committermpv <mikhail.ponikarov@opencascade.com>
Wed, 24 Dec 2014 07:24:00 +0000 (10:24 +0300)
src/Model/Model_Document.cpp

index 1e38773f03f964aa93d42e1b23b65273b6c0d61a..60f1634999ac896b092afb9acc82cbb007d15b3e 100644 (file)
@@ -205,32 +205,29 @@ bool Model_Document::save(const char* theFileName, std::list<std::string>& theRe
   myTransactionSave = myTransactionsCounter;
   if (isDone) {  // save also sub-documents if any
     theResults.push_back(TCollection_AsciiString(aPath).ToCString());
-    const std::set<std::string> aSubs = subDocuments(true);
+    const std::set<std::string> aSubs = subDocuments(false);
     std::set<std::string>::iterator aSubIter = aSubs.begin();
     for (; aSubIter != aSubs.end() && isDone; aSubIter++) {
-      isDone = subDoc(*aSubIter)->save(theFileName, theResults);
-    }
-    const std::set<std::string> 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);
       }
     }
   }