Make CollectionQuery subclass QSqlQuery, don't copy QSqlQuery

This commit is contained in:
Jonas Kvinge
2021-04-10 03:20:25 +02:00
parent 0c4edc4d17
commit 5a58ac2845
11 changed files with 187 additions and 115 deletions

View File

@@ -52,6 +52,7 @@
#include "song.h"
#include "songloader.h"
#include "tagreaderclient.h"
#include "database.h"
#include "engine/enginetype.h"
#include "engine/enginebase.h"
#include "collection/collectionbackend.h"
@@ -222,11 +223,14 @@ SongLoader::Result SongLoader::LoadLocal(const QString &filename) {
// Search in the database.
QUrl url = QUrl::fromLocalFile(filename);
CollectionQuery query;
QMutexLocker l(collection_->db()->Mutex());
QSqlDatabase db(collection_->db()->Connect());
CollectionQuery query(db, collection_->songs_table(), collection_->fts_table());
query.SetColumnSpec("%songs_table.ROWID, " + Song::kColumnSpec);
query.AddWhere("url", url.toEncoded());
if (collection_->ExecQuery(&query) && query.Next()) {
if (query.Exec() && query.Next()) {
// We may have many results when the file has many sections
do {
Song song(Song::Source_Collection);