From 2c81ba2df95cc07d5d147c8f3c7999c34848d274 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Mon, 13 Jun 2022 12:16:26 +0200 Subject: QThread: Clean up bindingStatusOrList if object gets deleted Deal with the case that the object gets deleted between a call to moveToThread and the start of the thread by removing the object from the list in that case. Fixes: QTBUG-104014 Pick-to: 6.4 Change-Id: Ib249b6e8e8dfbc4d1332bb99a57fa9d3cff16465 Reviewed-by: Qt CI Bot Reviewed-by: Volker Hilsheimer --- tests/auto/corelib/thread/qthread/tst_qthread.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index b60f5670dd..1cade32545 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -97,6 +97,8 @@ private slots: void terminateAndPrematureDestruction(); void terminateAndDoubleDestruction(); + + void bindingListCleanupAfterDelete(); }; enum { one_minute = 60 * 1000, five_minutes = 5 * one_minute }; @@ -1830,5 +1832,17 @@ void tst_QThread::terminateAndDoubleDestruction() TestObject obj; } +void tst_QThread::bindingListCleanupAfterDelete() +{ + QThread t; + auto optr = std::make_unique(); + optr->moveToThread(&t); + auto threadPriv = static_cast(QObjectPrivate::get(&t)); + auto list = threadPriv->m_statusOrPendingObjects.list(); + QVERIFY(list); + optr.reset(); + QVERIFY(list->empty()); +} + QTEST_MAIN(tst_QThread) #include "tst_qthread.moc" -- cgit v1.2.3