diff --git a/src/ProjectFileIO.cpp b/src/ProjectFileIO.cpp index 63eb27244..eafb094c5 100644 --- a/src/ProjectFileIO.cpp +++ b/src/ProjectFileIO.cpp @@ -288,7 +288,10 @@ void ProjectFileIO::SaveConnection() DiscardConnection(); mPrevDB = mDB; + mPrevFileName = mFileName; + mDB = nullptr; + SetFileName({}); } // Close any set-aside connection @@ -305,6 +308,7 @@ void ProjectFileIO::DiscardConnection() ); } mPrevDB = nullptr; + mPrevFileName.clear(); } } @@ -323,12 +327,17 @@ void ProjectFileIO::RestoreConnection() } } mDB = mPrevDB; + SetFileName(mPrevFileName); + + mPrevDB = nullptr; + mPrevFileName.clear(); } -void ProjectFileIO::UseConnection( sqlite3 *db ) +void ProjectFileIO::UseConnection( sqlite3 *db, const FilePath &filePath ) { wxASSERT(mDB == nullptr); mDB = db; + SetFileName( filePath ); } sqlite3 *ProjectFileIO::OpenDB(FilePath fileName) @@ -1350,7 +1359,7 @@ bool ProjectFileIO::SaveProject(const FilePath &fileName) // (also ensuring closing of one of the connections, with the cooperation // of the finally above) SaveConnection(); - UseConnection( newDB ); + UseConnection( newDB, fileName ); } auto db = DB(); diff --git a/src/ProjectFileIO.h b/src/ProjectFileIO.h index ff8821563..1485d8ec5 100644 --- a/src/ProjectFileIO.h +++ b/src/ProjectFileIO.h @@ -134,7 +134,7 @@ private: void RestoreConnection(); // Use a connection that is already open rather than invoke OpenDB - void UseConnection( sqlite3 *db ); + void UseConnection( sqlite3 *db, const FilePath &filePath ); sqlite3 *OpenDB(FilePath fileName = {}); bool CloseDB(); @@ -185,8 +185,9 @@ private: bool mBypass; sqlite3 *mPrevDB; + FilePath mPrevFileName; + sqlite3 *mDB; - FilePath mDBPath; TranslatableString mLastError; TranslatableString mLibraryError;