From 66223727c708e48009cbf297721aa2d0134b48d2 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 26 Jun 2019 07:56:49 +0200 Subject: Port from implicit to explicit atomic pointer operations The old code used the implicit conversions from QAtomicPointer to T* and vice versa. The semantics of these differ from the ones std::atomic uses, so we're going to deprecate these, like we did for load() and store(), too. This patch fixex some users of these APIs before we deprecate them. Change-Id: I0a88bb1c359392538bb64b511bfc62381a56a468 Reviewed-by: Thiago Macieira --- src/corelib/thread/qthread_unix.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib/thread/qthread_unix.cpp') diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index 89efbff6aa..38e9c1c3ec 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -141,7 +141,7 @@ static void destroy_current_thread_data(void *p) pthread_setspecific(current_thread_data_key, p); QThreadData *data = static_cast(p); if (data->isAdopted) { - QThread *thread = data->thread; + QThread *thread = data->thread.loadAcquire(); Q_ASSERT(thread); QThreadPrivate *thread_p = static_cast(QObjectPrivate::get(thread)); Q_ASSERT(!thread_p->finished); @@ -253,8 +253,8 @@ QThreadData *QThreadData::current(bool createIfNecessary) data->deref(); data->isAdopted = true; data->threadId.storeRelaxed(to_HANDLE(pthread_self())); - if (!QCoreApplicationPrivate::theMainThread) - QCoreApplicationPrivate::theMainThread = data->thread.loadRelaxed(); + if (!QCoreApplicationPrivate::theMainThread.loadAcquire()) + QCoreApplicationPrivate::theMainThread.storeRelease(data->thread.loadRelaxed()); } return data; } @@ -285,7 +285,7 @@ QAbstractEventDispatcher *QThreadPrivate::createEventDispatcher(QThreadData *dat else return new QEventDispatcherUNIX; #elif !defined(QT_NO_GLIB) - const bool isQtMainThread = data->thread == QCoreApplicationPrivate::mainThread(); + const bool isQtMainThread = data->thread.loadAcquire() == QCoreApplicationPrivate::mainThread(); if (qEnvironmentVariableIsEmpty("QT_NO_GLIB") && (isQtMainThread || qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB")) && QEventDispatcherGlib::versionSupported()) -- cgit v1.2.3