AUP3: UP-15 - cannot update a project

At least the project file doesn't get deleted now.
This commit is contained in:
Leland Lucius 2020-07-06 18:55:53 -05:00
parent 4206e1ff6d
commit 0bea15077b

View File

@ -266,7 +266,7 @@ bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs
// Always save a backup of the original project file // Always save a backup of the original project file
wxString safetyFileName; wxString safetyFileName;
if (wxFileExists(fileName)) if (fromSaveAs && wxFileExists(fileName))
{ {
#ifdef __WXGTK__ #ifdef __WXGTK__
safetyFileName = fileName + wxT("~"); safetyFileName = fileName + wxT("~");
@ -303,11 +303,14 @@ bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs
wxICON_ERROR, wxICON_ERROR,
&window); &window);
if (wxFileExists(fileName)) if (fromSaveAs)
{ {
wxRemoveFile(fileName); if (wxFileExists(fileName))
{
wxRemoveFile(fileName);
}
wxRename(safetyFileName, fileName);
} }
wxRename(safetyFileName, fileName);
return false; 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 // 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 // the .bak file (because it now does not fit our block files anymore
// anyway). // anyway).
wxRemoveFile(safetyFileName); if (!safetyFileName.empty())
{
wxRemoveFile(safetyFileName);
}
return true; return true;
} }