QThread: use load/store operations with explicit ordering

The implicit load is an acquire, which isn't necessary in any of these
cases, including the two liens changing the store: they were creating a
temporary QAtomicPointer, which introduced the loadAcquire().

I've left the qCDebug() lines alone.

Pick-to: 6.5
Change-Id: If45e068eaaf3cd4d2c81fffd1459a779b4eb4110
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
(cherry picked from commit 6806391600b5398d4fdb3c4d2d5e442289522756)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2024-10-16 17:40:58 -07:00 committed by Qt Cherry-pick Bot
parent 8ebf6dcd12
commit c3fd08e42c
2 changed files with 3 additions and 3 deletions

View File

@ -178,7 +178,7 @@ QThreadData *QThreadData::current(bool createIfNecessary)
data = new QThreadData; data = new QThreadData;
QT_TRY { QT_TRY {
set_thread_data(data); set_thread_data(data);
data->thread = new QAdoptedThread(data); data->thread.storeRelease(new QAdoptedThread(data));
} QT_CATCH(...) { } QT_CATCH(...) {
clear_thread_data(); clear_thread_data();
data->deref(); data->deref();

View File

@ -76,7 +76,7 @@ QThreadData *QThreadData::current(bool createIfNecessary)
// avoid recursion. // avoid recursion.
TlsSetValue(qt_current_thread_data_tls_index, threadData); TlsSetValue(qt_current_thread_data_tls_index, threadData);
QT_TRY { QT_TRY {
threadData->thread = new QAdoptedThread(threadData); threadData->thread.storeRelease(new QAdoptedThread(threadData));
} QT_CATCH(...) { } QT_CATCH(...) {
TlsSetValue(qt_current_thread_data_tls_index, 0); TlsSetValue(qt_current_thread_data_tls_index, 0);
threadData->deref(); threadData->deref();
@ -101,7 +101,7 @@ QThreadData *QThreadData::current(bool createIfNecessary)
0, 0,
FALSE, FALSE,
DUPLICATE_SAME_ACCESS); DUPLICATE_SAME_ACCESS);
qt_watch_adopted_thread(realHandle, threadData->thread); qt_watch_adopted_thread(realHandle, threadData->thread.loadRelaxed());
} }
} }
return threadData; return threadData;