Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 02445c30 authored by Allan Sandfeld Jensen's avatar Allan Sandfeld Jensen Committed by Albert Astals Cid

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
parent eb2770b2
......@@ -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();
}
......
......@@ -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();
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment