From 752ee255590c775b7378b2703a3ba6aec0375d0c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 12 Nov 2024 09:38:37 -0800 Subject: [PATCH] QCoreApplication: remove now-unnecessary thread affinity check Partially reverts commit 65953e05d3d9aefd158d4073820083155aaae5e4 (the rest will be addressed in the next commit) now that we have an atomic access to the QCoreApplication instance. This thread-affinity check code was there because the code had a data race in accessing QCoreApplication::self. It ensured that we only read that variable if the receiver was in the main thread, because if a receiver is not in the main thread, then it can't be QCoreApplication. Change-Id: I09618961cca80fef2dc1fffdab65316164023207 Reviewed-by: Ivan Solovev (cherry picked from commit a90349aa2141767147498d8f6a6d69dc25af89bc) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/kernel/qcoreapplication.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index b3ae47d0c81..3cb146013f7 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -1299,9 +1299,7 @@ bool QCoreApplicationPrivate::sendThroughApplicationEventFilters(QObject *receiv bool QCoreApplicationPrivate::sendThroughObjectEventFilters(QObject *receiver, QEvent *event) { - if ((receiver->d_func()->threadData.loadRelaxed()->thread.loadAcquire() != mainThread() - || receiver != qApp) - && receiver->d_func()->extraData) { + if (receiver != qApp && receiver->d_func()->extraData) { for (qsizetype i = 0; i < receiver->d_func()->extraData->eventFilters.size(); ++i) { QObject *obj = receiver->d_func()->extraData->eventFilters.at(i); if (!obj)