From 49b2983272951cc64c63cda8cd0b57be57e8b8b5 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 24 May 2012 08:47:58 +0000 Subject: [PATCH] Fix regression of Save()/SaveAs() operation (multi-file mode) caused by previous integrations. --- src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index 9669d0a63..d52b629eb 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -528,6 +528,9 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, return false; } + // Store previous URL + std::string anOldName = aStudy->Name(); + //Create a temporary url to which the study is saved std::string aUrl = SALOMEDSImpl_Tool::GetTmpDir() + SALOMEDSImpl_Tool::GetNameFromPath(aStudyUrl); @@ -568,7 +571,9 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, } } - //std::string anOldName = aStudy->Name(); + // VSR: set URL to new file name + // VSR: remember to set previous name if save operation fails + aStudy->URL(aStudyUrl); // To change for Save // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything?? @@ -771,16 +776,19 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, catch (HDFexception) { _errorCode = "HDFexception ! "; + aStudy->URL( anOldName ); // VSR: restore previous url if operation is failed return false; } catch(std::exception& exc) { _errorCode = const_cast(exc.what()); + aStudy->URL( anOldName ); // VSR: restore previous url if operation is failed return false; } catch(...) { _errorCode = "Unknown exception ! "; + aStudy->URL( anOldName ); // VSR: restore previous url if operation is failed return false; } if (theASCII) { // save file in ASCII format @@ -804,7 +812,10 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, // Iterate and move files in the temporary directory FILE* fp = fopen(aTmpFile.c_str(), "rb"); - if(!fp) return false; + if(!fp) { + aStudy->URL( anOldName ); // VSR: restore previous url if operation is failed + return false; + } char* buffer = new char[2047]; int errors = 0; while(!feof(fp) && !errors) { @@ -838,8 +849,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, #endif if ( !errors ) { - // and finally, if all is done without errors, store new URL and mark study as Saved - aStudy->URL(aStudyUrl); + // VSR: finally, if all is done without errors, mark study as Saved aStudy->IsSaved(true); } -- 2.39.2