diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-06-17 12:36:21 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-06-20 19:06:20 +0200 |
commit | 0bd287627508c61a7abfd6430d8c1243ea153081 (patch) | |
tree | 310868183ec852365f7970c8980727679d2d9abd /tests | |
parent | 903bde19a416d82fc255777955237fd410acd690 (diff) |
Avoid misleading bindingStatus
Set it to nullptr on clear, and deal with possibly null bindingStatus.
Task-number: QTBUG-101177
Task-number: QTBUG-102403
Pick-to: 6.4
Change-Id: I66cb4d505a4f7b377dc90b45ac13834fca19d399
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp index 92de7725e4..c0471890ee 100644 --- a/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp +++ b/tests/auto/corelib/kernel/qproperty/tst_qproperty.cpp @@ -79,6 +79,7 @@ private slots: void noFakeDependencies(); void threadSafety(); + void threadSafety2(); void bindablePropertyWithInitialization(); void noDoubleNotification(); @@ -1694,7 +1695,7 @@ void tst_QProperty::threadSafety() auto child1 = new ThreadSafetyTester(obj1); obj1->moveToThread(&workerThread); const auto mainThreadBindingStatus = QtPrivate::getBindingStatus({}); - QCOMPARE(qGetBindingStorage(child1)->status({}), mainThreadBindingStatus); + QCOMPARE(qGetBindingStorage(child1)->status({}), nullptr); workerThread.start(); bool correctStatus = false; @@ -1743,6 +1744,41 @@ void tst_QProperty::threadSafety() QCOMPARE(obj3->objectName(), "moved again"); } +class QPropertyUsingThread : public QThread +{ +public: + QPropertyUsingThread(QObject **dest, QThread *destThread) : dest(dest), destThread(destThread) {} + void run() override + { + scopedObj1.reset(new ThreadSafetyTester()); + scopedObj1->setObjectName("test"); + QObject *child = new ThreadSafetyTester(scopedObj1.get()); + child->setObjectName("child"); + exec(); + scopedObj1->moveToThread(destThread); + *dest = scopedObj1.release(); + } + std::unique_ptr<ThreadSafetyTester> scopedObj1; + QObject **dest; + QThread *destThread; +}; + +void tst_QProperty::threadSafety2() +{ + std::unique_ptr<QObject> movedObj; + { + QObject *tmp = nullptr; + QPropertyUsingThread workerThread(&tmp, QThread::currentThread()); + workerThread.start(); + workerThread.quit(); + workerThread.wait(); + movedObj.reset(tmp); + } + + QCOMPARE(movedObj->objectName(), "test"); + QCOMPARE(movedObj->children().first()->objectName(), "child"); +} + struct CustomType { CustomType() = default; |