aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <[email protected]>2018-03-15 17:38:25 +0100
committerAlbert Astals Cid <[email protected]>2018-03-15 17:39:16 +0100
commit02445c3022c96c4cf8734034ec49c0cb9b05d1ea (patch)
tree595cbe867cd6d7e10aa99e2149bce1d3364c2da9
parenteb2770b2d690e04c26184b7d492a6e4a08f6f2fb (diff)
Fix QSqlQuery warnings
Summary: A default constructed QSqlQuery is not a passive null-value but a query prepared for the default database which may not be allowed in the current thread. Instead try connecting to the akonadi default database. BUG: 391783 Reviewers: mlaurent, dvratil Reviewed By: dvratil Subscribers: dvratil, ngraham, #kde_pim Tags: #kde_pim Differential Revision: https://phabricator.kde.org/D11273
-rw-r--r--src/server/handler/fetchhelper.cpp8
-rw-r--r--src/server/handler/list.cpp4
-rw-r--r--src/server/storage/querybuilder.cpp3
3 files changed, 8 insertions, 7 deletions
diff --git a/src/server/handler/fetchhelper.cpp b/src/server/handler/fetchhelper.cpp
index b7b19e1..209bd28 100644
--- a/src/server/handler/fetchhelper.cpp
+++ b/src/server/handler/fetchhelper.cpp
@@ -369,7 +369,7 @@ bool FetchHelper::fetchItems()
}
// build part query if needed
BEGIN_TIMER(parts)
- QSqlQuery partQuery;
+ QSqlQuery partQuery(DataStore::self()->database());
if (!mFetchScope.requestedParts().isEmpty() || mFetchScope.fullPayload() || mFetchScope.allAttributes()) {
partQuery = buildPartQuery(mFetchScope.requestedParts(), mFetchScope.fullPayload(), mFetchScope.allAttributes());
}
@@ -377,7 +377,7 @@ bool FetchHelper::fetchItems()
// build flag query if needed
BEGIN_TIMER(flags)
- QSqlQuery flagQuery;
+ QSqlQuery flagQuery(DataStore::self()->database());
if (mFetchScope.fetchFlags()) {
flagQuery = buildFlagQuery();
}
@@ -385,14 +385,14 @@ bool FetchHelper::fetchItems()
// build tag query if needed
BEGIN_TIMER(tags)
- QSqlQuery tagQuery;
+ QSqlQuery tagQuery(DataStore::self()->database());
if (mFetchScope.fetchTags()) {
tagQuery = buildTagQuery();
}
END_TIMER(tags)
BEGIN_TIMER(vRefs)
- QSqlQuery vRefQuery;
+ QSqlQuery vRefQuery(DataStore::self()->database());
if (mFetchScope.fetchVirtualReferences()) {
vRefQuery = buildVRefQuery();
}
diff --git a/src/server/handler/list.cpp b/src/server/handler/list.cpp
index 3907503..eada0f7 100644
--- a/src/server/handler/list.cpp
+++ b/src/server/handler/list.cpp
@@ -445,8 +445,8 @@ void List::retrieveCollections(const Collection &topParent, int depth)
const int querySizeLimit = 999;
int mimetypeQueryStart = 0;
int attributeQueryStart = 0;
- QSqlQuery mimeTypeQuery;
- QSqlQuery attributeQuery;
+ QSqlQuery mimeTypeQuery(DataStore::self()->database());
+ QSqlQuery attributeQuery(DataStore::self()->database());
auto it = mCollections.begin();
while (it != mCollections.end()) {
const Collection col = it.value();
diff --git a/src/server/storage/querybuilder.cpp b/src/server/storage/querybuilder.cpp
index 88b1866..6a19f91 100644
--- a/src/server/storage/querybuilder.cpp
+++ b/src/server/storage/querybuilder.cpp
@@ -101,6 +101,7 @@ QueryBuilder::QueryBuilder(const QString &table, QueryBuilder::QueryType type)
: mTable(table)
#ifndef QUERYBUILDER_UNITTEST
, mDatabaseType(DbType::type(DataStore::self()->database()))
+ , mQuery(DataStore::self()->database())
#else
, mDatabaseType(DbType::Unknown)
#endif
@@ -356,7 +357,7 @@ bool QueryBuilder::exec()
if (QueryCache::contains(statement)) {
mQuery = QueryCache::query(statement);
} else {
- mQuery = QSqlQuery(DataStore::self()->database());
+ mQuery.clear();
mQuery.prepare(statement);
QueryCache::insert(statement, mQuery);
}