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();
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;
}