From e7d76d79e8d48b7d38ac635e9ac8c3b667c1aaa2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 23 Jun 2020 16:26:35 -0700 Subject: [PATCH] QThread: Fix unnecessary stricter accesses to QThreadData::thread Commit ec6556a2b99df373eb43ca009340a7f0f19bacbd changed the member from a plain pointer to a QAtomicPointer. Not all accesses were caught. Pick-to: 5.15 Change-Id: I3d4f433ff6e94fd390a9fffd161b4ff25508c48d Reviewed-by: David Faure --- src/corelib/thread/qthread.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index 36e9b2a7a2..6e31ca4fbb 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -415,7 +415,7 @@ QThread::QThread(QObject *parent) { Q_D(QThread); // fprintf(stderr, "QThreadData %p created for thread %p\n", d->data, this); - d->data->thread = this; + d->data->thread.storeRelaxed(this); } /*! @@ -426,7 +426,7 @@ QThread::QThread(QThreadPrivate &dd, QObject *parent) { Q_D(QThread); // fprintf(stderr, "QThreadData %p taken from private data for thread %p\n", d->data, this); - d->data->thread = this; + d->data->thread.storeRelaxed(this); } /*! @@ -451,7 +451,7 @@ QThread::~QThread() if (d->running && !d->finished && !d->data->isAdopted) qFatal("QThread: Destroyed while thread is still running"); - d->data->thread = nullptr; + d->data->thread.storeRelease(nullptr); } } @@ -797,7 +797,7 @@ QThread::QThread(QObject *parent) : QObject(*(new QThreadPrivate), parent) { Q_D(QThread); - d->data->thread = this; + d->data->thread.storeRelaxed(this); } QThread::~QThread() @@ -915,7 +915,7 @@ QThread::QThread(QThreadPrivate &dd, QObject *parent) { Q_D(QThread); // fprintf(stderr, "QThreadData %p taken from private data for thread %p\n", d->data, this); - d->data->thread = this; + d->data->thread.storeRelaxed(this); } QThreadPrivate::QThreadPrivate(QThreadData *d) : data(d ? d : new QThreadData) @@ -924,7 +924,7 @@ QThreadPrivate::QThreadPrivate(QThreadData *d) : data(d ? d : new QThreadData) QThreadPrivate::~QThreadPrivate() { - data->thread = nullptr; // prevent QThreadData from deleting the QThreadPrivate (again). + data->thread.storeRelease(nullptr); // prevent QThreadData from deleting the QThreadPrivate (again). delete data; }