QSqlDatabase: Rename currentThread() to thread()
... to be in sync with QObject naming. This amends b4c63b89dfe136d0579bf1b6422c4d878cdd74ab. Change-Id: I25301f65aa880205d8c0cfd6f4bfa9fdba34a01c Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
60061f679c
commit
5a7c2cbabb
@ -1377,7 +1377,7 @@ bool QSqlDatabase::moveToThread(QThread *targetThread)
|
|||||||
|
|
||||||
Returns a pointer to the associated QThread instance.
|
Returns a pointer to the associated QThread instance.
|
||||||
*/
|
*/
|
||||||
QThread *QSqlDatabase::currentThread() const
|
QThread *QSqlDatabase::thread() const
|
||||||
{
|
{
|
||||||
if (auto drv = driver())
|
if (auto drv = driver())
|
||||||
return drv->thread();
|
return drv->thread();
|
||||||
|
@ -82,7 +82,7 @@ public:
|
|||||||
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy);
|
void setNumericalPrecisionPolicy(QSql::NumericalPrecisionPolicy precisionPolicy);
|
||||||
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
|
QSql::NumericalPrecisionPolicy numericalPrecisionPolicy() const;
|
||||||
bool moveToThread(QThread *targetThread);
|
bool moveToThread(QThread *targetThread);
|
||||||
QThread *currentThread() const;
|
QThread *thread() const;
|
||||||
|
|
||||||
QSqlDriver* driver() const;
|
QSqlDriver* driver() const;
|
||||||
|
|
||||||
|
@ -2344,20 +2344,20 @@ void tst_QSqlDatabase::moveToThread()
|
|||||||
auto clonedDb = QSqlDatabase::cloneDatabase(db, "clonedDb");
|
auto clonedDb = QSqlDatabase::cloneDatabase(db, "clonedDb");
|
||||||
auto mainThread = QThread::currentThread();
|
auto mainThread = QThread::currentThread();
|
||||||
CHECK_DATABASE(db);
|
CHECK_DATABASE(db);
|
||||||
QCOMPARE(db.currentThread(), mainThread);
|
QCOMPARE(db.thread(), mainThread);
|
||||||
QCOMPARE(clonedDb.currentThread(), mainThread);
|
QCOMPARE(clonedDb.thread(), mainThread);
|
||||||
std::unique_ptr<QThread> t(QThread::create([&] {
|
std::unique_ptr<QThread> t(QThread::create([&] {
|
||||||
db.moveToThread(mainThread);
|
db.moveToThread(mainThread);
|
||||||
QThread::currentThread()->exit();
|
QThread::currentThread()->exit();
|
||||||
}));
|
}));
|
||||||
db.moveToThread(t.get());
|
db.moveToThread(t.get());
|
||||||
QCOMPARE(db.currentThread(), t.get());
|
QCOMPARE(db.thread(), t.get());
|
||||||
QCOMPARE(clonedDb.currentThread(), mainThread);
|
QCOMPARE(clonedDb.thread(), mainThread);
|
||||||
t->start();
|
t->start();
|
||||||
QTRY_VERIFY(t->isRunning());
|
QTRY_VERIFY(t->isRunning());
|
||||||
QTRY_VERIFY(t->wait(30000));
|
QTRY_VERIFY(t->wait(30000));
|
||||||
QCOMPARE(db.currentThread(), mainThread);
|
QCOMPARE(db.thread(), mainThread);
|
||||||
QCOMPARE(clonedDb.currentThread(), mainThread);
|
QCOMPARE(clonedDb.thread(), mainThread);
|
||||||
db = QSqlDatabase();
|
db = QSqlDatabase();
|
||||||
clonedDb = QSqlDatabase();
|
clonedDb = QSqlDatabase();
|
||||||
QSqlDatabase::removeDatabase("clonedDb");
|
QSqlDatabase::removeDatabase("clonedDb");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user