Salome HOME
restore study flags after backup
authormbs <martin.bernhard@opencascade.com>
Thu, 21 Dec 2023 12:08:40 +0000 (12:08 +0000)
committermbs <martin.bernhard@opencascade.com>
Fri, 19 Jan 2024 23:08:16 +0000 (23:08 +0000)
src/SalomeApp/SalomeApp_Study.cxx

index 6d97460513d09610720625cf81714964b819b9fb..ecd50357e20ba2bcb68552bb36191fc40beaef0f 100644 (file)
@@ -618,6 +618,10 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/
   ARG(theFileName);
   ARG(isBackup);
 
+  bool wasSaved = isSaved();
+  bool wasModified = isModified();
+  std::string oldName = (studyDS() ? studyDS()->Name() : "");
+  std::string oldURL = (studyDS() ? studyDS()->URL() : "");
   bool store = application()->resourceMgr()->booleanValue( "Study", "store_visual_state", false );
   if ( store && !isBackup )
     SalomeApp_VisualState( (SalomeApp_Application*)application() ).storeState();
@@ -647,13 +651,24 @@ bool SalomeApp_Study::saveDocumentAs( const QString& theFileName, bool isBackup/
   bool isMultiFile = resMgr->booleanValue( "Study", "multi_file", false );
   bool isAscii = resMgr->booleanValue( "Study", "ascii_file", false );
   bool res = studyDS()->SaveAs( theFileName.toUtf8().data(), isMultiFile, isAscii )
-    && CAM_Study::saveDocumentAs( theFileName );
+    && CAM_Study::saveDocumentAs( theFileName, isBackup );
 
   res = res && saveStudyData(theFileName, 0); // 0 means persistence file
 
   if ( res && !isBackup)
     emit saved( this );
 
+  if (isBackup) {
+    // Restore the isSaved and isModified flag after having done backup
+    setIsSaved(wasSaved);
+    setIsModified(wasModified);
+    // If the document hasn't been saved before, reset here its name and URL
+    if (!wasSaved && studyDS()) {
+      studyDS()->URL(oldURL);
+      studyDS()->Name(oldName);
+    }
+  }
+
   return res;
 }