summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-01-20 22:30:30 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-01-24 21:35:09 +0100
commite752c77b35185fa51cdc3684329a9733abe2be3b (patch)
tree954d4495059b506a3055dc2143b6fb5f4f9ce30f /tests/auto/corelib/kernel/qobject/tst_qobject.cpp
parent294da15696eefd101e19694e0b9842357bfe9321 (diff)
QObject: Let moveToThread return succcess state
Add bool QObjectPrivate::moveToThread() which returns the success state of the attempt to move the object to the new thread. For Qt7 the public signature of QObject::moveToThread() should be changed to directly return this value. [ChangeLog][QtCore][QObject] QObject::moveToThread() now returns a boolean success state. Pick-to: 6.7 Change-Id: I8441c8155a76b804b473ab9c45c2be6840ef1677 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qobject/tst_qobject.cpp')
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index b626d0e3c4..0532841ac8 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -1870,13 +1870,15 @@ void tst_QObject::moveToThread()
QObject *child = new QObject(object);
QCOMPARE(object->thread(), currentThread);
QCOMPARE(child->thread(), currentThread);
- object->moveToThread(0);
+ QVERIFY(object->moveToThread(nullptr));
QCOMPARE(object->thread(), (QThread *)0);
QCOMPARE(child->thread(), (QThread *)0);
- object->moveToThread(currentThread);
+ QVERIFY(object->moveToThread(currentThread));
QCOMPARE(object->thread(), currentThread);
QCOMPARE(child->thread(), currentThread);
- object->moveToThread(0);
+ QTest::ignoreMessage(QtWarningMsg, "QObject::moveToThread: Cannot move objects with a parent");
+ QVERIFY(!child->moveToThread(nullptr));
+ QVERIFY(object->moveToThread(nullptr));
QCOMPARE(object->thread(), (QThread *)0);
QCOMPARE(child->thread(), (QThread *)0);
// can delete an object with no thread anywhere