Salome HOME
Merge branch 'master' into V9_3_BR
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 2660cb93b4a6cd9f5937269e31258f04cf045ff9..b42e4d003c5285fa3ed96fee4a55056cf46a70a3 100644 (file)
@@ -1073,15 +1073,23 @@ bool XGUI_Workshop::onSave()
     aMgr->blockAutoUpdate(false);
 
   std::list<std::string> aFiles;
-  saveDocument(myTmpDir.path(), aFiles);
-  if (!XGUI_CompressFiles::compress(myCurrentFile, aFiles))
-    return false;
+  // issue #2899: create a temporary directory, save and then remove it
+#ifdef HAVE_SALOME
+  std::string aTmpDir = XGUI_Tools::getTmpDirByEnv("SALOME_TMP_DIR");
+#else
+  std::string aTmpDir = XGUI_Tools::getTmpDirByEnv("");
+#endif
+  saveDocument(QString(aTmpDir.c_str()), aFiles);
+  bool aResult = XGUI_CompressFiles::compress(myCurrentFile, aFiles);
+  XGUI_Tools::removeTemporaryFiles(aTmpDir, aFiles);
 
-  updateCommandStatus();
+  if (aResult) {
+    updateCommandStatus();
 #ifndef HAVE_SALOME
     myMainWindow->setModifiedState(false);
 #endif
-  return true;
+  }
+  return aResult;
 }
 
 //******************************************************
@@ -2700,12 +2708,28 @@ void XGUI_Workshop::synchronizeGroupInViewer(const DocumentPtr& theDoc,
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
       if (aRes.get() && (!aRes->shape().get() || aRes->shape()->isNull()))
         continue;
-      myDisplayer->display(aObj, false);
+      ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
+      if (aResBody.get())
+        synchronizeResultTree(aResBody, false);
+      else
+        myDisplayer->display(aObj, false);
     }
   }
   if (theUpdateViewer)
     myDisplayer->updateViewer();
 }
+
+void XGUI_Workshop::synchronizeResultTree(const ResultBodyPtr& theRes, bool theUpdateViewer)
+{
+  if (theRes->numberOfSubs() > 0)
+    for (int i = 0; i < theRes->numberOfSubs(); i++) {
+      ResultBodyPtr aRes = theRes->subResult(i);
+      if (aRes.get())
+        synchronizeResultTree(aRes, theUpdateViewer);
+    }
+  else
+    myDisplayer->display(theRes, theUpdateViewer);
+}
 #endif
 
 //******************************************************