QThread: Initialize bindingStatus for adopted threads
If we create a QThread from QThread::current(), we want it to have a correct value for its bindingStatus. Thus, initialize bindingStatus in the ctor of QAdoptedThread. Task-number: QTBUG-101177 Task-number: QTBUG-102403 Pick-to: 6.4 6.3 Change-Id: I3ef27ed62c5dc25eed05d551c72743a1b8528318 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
7e0711e0c0
commit
268ff00ef5
@ -129,8 +129,9 @@ QAdoptedThread::QAdoptedThread(QThreadData *data)
|
||||
d_func()->running = true;
|
||||
d_func()->finished = false;
|
||||
init();
|
||||
d_func()->m_statusOrPendingObjects.setStatusAndClearList(
|
||||
QtPrivate::getBindingStatus({}));
|
||||
#endif
|
||||
|
||||
// fprintf(stderr, "new QAdoptedThread = %p\n", this);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
#include <qdebug.h>
|
||||
#include <qmetaobject.h>
|
||||
#include <qscopeguard.h>
|
||||
#include <private/qobject_p.h>
|
||||
#include <private/qthread_p.h>
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
#include <pthread.h>
|
||||
@ -68,6 +70,7 @@ private slots:
|
||||
void adoptedThreadExecFinished();
|
||||
void adoptMultipleThreads();
|
||||
void adoptMultipleThreadsOverlap();
|
||||
void adoptedThreadBindingStatus();
|
||||
|
||||
void exitAndStart();
|
||||
void exitAndExec();
|
||||
@ -941,6 +944,20 @@ void tst_QThread::adoptMultipleThreadsOverlap()
|
||||
QCOMPARE(recorder.activationCount.loadRelaxed(), numThreads);
|
||||
}
|
||||
|
||||
void tst_QThread::adoptedThreadBindingStatus()
|
||||
{
|
||||
NativeThreadWrapper nativeThread;
|
||||
nativeThread.setWaitForStop();
|
||||
|
||||
nativeThread.startAndWait();
|
||||
QVERIFY(nativeThread.qthread);
|
||||
auto privThread = static_cast<QThreadPrivate *>(QObjectPrivate::get(nativeThread.qthread));
|
||||
QVERIFY(privThread->m_statusOrPendingObjects.bindingStatus());
|
||||
|
||||
nativeThread.stop();
|
||||
nativeThread.join();
|
||||
}
|
||||
|
||||
// Disconnects on WinCE
|
||||
void tst_QThread::stressTest()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user