summaryrefslogtreecommitdiffstats
path: root/tests/auto/sql
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2018-12-21 14:34:28 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2018-12-23 11:41:36 +0000
commitf03941e4113e2c8c0a594592be44efc92614ec9d (patch)
tree158111ff8335c3923c41a86a7b64788297aab8ee /tests/auto/sql
parent37b30983023a2e1fd5d7250ee2d15d8574a5cc2d (diff)
Add overload of QSqlDatabase::cloneDatabase to allow cloning cross threads
Since QSqlDatabase::database() cannot be used to access another database from another thread, then the overload is provided to make it possible to clone with just the connection name. This will handle the cloning internally safely then. Fixes: QTBUG-72545 Change-Id: I861cc5aa2c38c1e3797f6f086594a1228f05bada Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/sql')
-rw-r--r--tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
index bdfa957083..afc3fb1ec9 100644
--- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp
@@ -2422,6 +2422,16 @@ public slots:
QSqlDatabase invalidDb = QSqlDatabase::database("invalid");
QVERIFY(!invalidDb.isValid());
+
+ {
+ QSqlDatabase clonedDatabase = QSqlDatabase::cloneDatabase(dbName, "CloneDB");
+ QVERIFY(!clonedDatabase.isOpen());
+ QVERIFY(clonedDatabase.isValid());
+ QVERIFY(clonedDatabase.open());
+ QVERIFY(clonedDatabase.isOpen());
+ clonedDatabase.close();
+ }
+
QThread::currentThread()->exit();
}
private: