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 <ivan.solovev@qt.io>
(cherry picked from commit a90349aa2141767147498d8f6a6d69dc25af89bc)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Thiago Macieira 2024-11-12 09:38:37 -08:00 committed by Qt Cherry-pick Bot
parent a00bff6525
commit 752ee25559

View File

@ -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)