1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-30 23:49:28 +02:00

Factor ProjectFileIO::GetConnection (returning reference not pointer)

This commit is contained in:
Paul Licameli 2020-09-02 14:36:16 -04:00
parent 4742f4ce1c
commit c9dec8f5a9
2 changed files with 13 additions and 2 deletions

View File

@ -256,7 +256,7 @@ ProjectFileIO::~ProjectFileIO()
{
}
sqlite3 *ProjectFileIO::DB()
DBConnection &ProjectFileIO::GetConnection()
{
auto &curConn = CurrConn();
if (!curConn)
@ -270,9 +270,18 @@ sqlite3 *ProjectFileIO::DB()
}
}
return curConn->DB();
return *curConn;
}
sqlite3 *ProjectFileIO::DB()
{
return GetConnection().DB();
}
/*!
@pre *CurConn() does not exist
@post *CurConn() exists or return value is false
*/
bool ProjectFileIO::OpenConnection(FilePath fileName /* = {} */)
{
auto &curConn = CurrConn();

View File

@ -142,6 +142,8 @@ public:
// 0 for success or non-zero to stop the query
using ExecCB = std::function<int(int cols, char **vals, char **names)>;
DBConnection &GetConnection();
private:
void WriteXMLHeader(XMLWriter &xmlFile) const;
void WriteXML(XMLWriter &xmlFile, bool recording = false, const std::shared_ptr<TrackList> &tracks = nullptr) /* not override */;