From f03941e4113e2c8c0a594592be44efc92614ec9d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 21 Dec 2018 14:34:28 +0100 Subject: 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 --- tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/auto/sql') 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: -- cgit v1.2.3