diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index e8a499ff2..a3df16f57 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -1913,7 +1913,7 @@ bool ProjectFileIO::LoadProject(const FilePath &fileName) return true; } -bool ProjectFileIO::SaveProject(const FilePath &fileName) +bool ProjectFileIO::SaveProject(const FilePath &fileName, const std::shared_ptr &lastSaved) { // If we're saving to a different file than the current one, then copy the // current to the new file and make it the active file. @@ -1930,15 +1930,14 @@ bool ProjectFileIO::SaveProject(const FilePath &fileName) // Autosave no longer needed in original project file AutoSaveDelete(); - // Save the original database connection and try to switch to a new one - SaveConnection(); + // Try to vacuum the orignal project file + Vacuum(lastSaved); + + // Save to close the original project file now + CloseProject(); // And make it the active project file UseConnection(std::move(newConn), fileName); - - // The Save was successful, so now it is safe to abandon the - // original connection - DiscardConnection(); } else { diff --git a/src/ProjectFileIO.h b/src/ProjectFileIO.h index 18b548da5..5699cace9 100644 --- a/src/ProjectFileIO.h +++ b/src/ProjectFileIO.h @@ -83,7 +83,7 @@ public: bool ImportProject(const FilePath &fileName); bool LoadProject(const FilePath &fileName); - bool SaveProject(const FilePath &fileName); + bool SaveProject(const FilePath &fileName, const std::shared_ptr &lastSaved); bool SaveCopy(const FilePath& fileName); wxLongLong GetFreeDiskSpace(); diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index c97b8de3c..a743eaf51 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -148,7 +148,7 @@ auto ProjectFileManager::ReadProjectFile( const FilePath &fileName ) if (!projectFileIO.IsTemporary()) { - projectFileIO.SaveProject(fileName); + projectFileIO.SaveProject(fileName, nullptr); resaved = true; } @@ -302,7 +302,7 @@ bool ProjectFileManager::DoSave(const FilePath & fileName, const bool fromSaveAs } } - bool success = projectFileIO.SaveProject(fileName); + bool success = projectFileIO.SaveProject(fileName, mLastSavedTracks); if (!success) { AudacityMessageBox(