From 0bea15077bf39b8e0d87b65b278e694dc9c991e3 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Mon, 6 Jul 2020 18:55:53 -0500 Subject: [PATCH] AUP3: UP-15 - cannot update a project At least the project file doesn't get deleted now. --- src/ProjectFileManager.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index b1f07463a..21214ffcf 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -266,7 +266,7 @@ bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs // Always save a backup of the original project file wxString safetyFileName; - if (wxFileExists(fileName)) + if (fromSaveAs && wxFileExists(fileName)) { #ifdef __WXGTK__ safetyFileName = fileName + wxT("~"); @@ -303,11 +303,14 @@ bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs wxICON_ERROR, &window); - if (wxFileExists(fileName)) + if (fromSaveAs) { - wxRemoveFile(fileName); + if (wxFileExists(fileName)) + { + wxRemoveFile(fileName); + } + wxRename(safetyFileName, fileName); } - wxRename(safetyFileName, fileName); return false; } @@ -330,7 +333,10 @@ bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs // If we get here, saving the project was successful, so we can DELETE // the .bak file (because it now does not fit our block files anymore // anyway). - wxRemoveFile(safetyFileName); + if (!safetyFileName.empty()) + { + wxRemoveFile(safetyFileName); + } return true; }