mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
SqlDatabase: Skip copy when executing query on main thread
This commit is contained in:
parent
5fb492d033
commit
d19f5de7bf
@ -19,6 +19,7 @@
|
||||
|
||||
#include <QThread>
|
||||
#include <QMutexLocker>
|
||||
#include <QApplication>
|
||||
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
||||
@ -54,8 +55,13 @@ QSqlDatabase SqlDatabase::databaseForThread(QThread* thread)
|
||||
return m_databases[thread];
|
||||
}
|
||||
|
||||
QSqlQuery SqlDatabase::exec(const QSqlQuery &query)
|
||||
QSqlQuery SqlDatabase::exec(QSqlQuery &query)
|
||||
{
|
||||
if (QThread::currentThread() == qApp->thread()) {
|
||||
query.exec();
|
||||
return query;
|
||||
}
|
||||
|
||||
QSqlQuery out(databaseForThread(QThread::currentThread()));
|
||||
out.prepare(query.lastQuery());
|
||||
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
QSqlDatabase databaseForThread(QThread* thread);
|
||||
|
||||
// Executes query using correct database for current thread
|
||||
QSqlQuery exec(const QSqlQuery &query);
|
||||
QSqlQuery exec(QSqlQuery &query);
|
||||
|
||||
// Executes query asynchronously on one thread from QThreadPool
|
||||
QFuture<QSqlQuery> execAsync(const QSqlQuery &query);
|
||||
|
Loading…
Reference in New Issue
Block a user