Doc: update future direction of QCoreApplication::notify()
Change the Qt version for future directions of
QCoreApplication::notify() to 7. The required changes were not
done in Qt 6 as planned. Add the code that is implementing those
changes for Qt 7.0.0.
This amends 4fe865ac7a
.
[ChangeLog][Future direction notices] In Qt 7,
QCoreApplication::notify() will not be called for events being delivered
to objects outside the main thread. The reason for that is that the main
application object may begin destruction while those threads are still
delivering events, which is undefined behavior. Applications that
currently override notify() and use that function outside the main
thread are advised to find other solutions in the mean time.
Change-Id: I4dd2193092542474962cdcde4921f38b173f2f00
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
7c4aa794ca
commit
ad692a1fbb
@ -1123,6 +1123,11 @@ bool QCoreApplication::notifyInternal2(QObject *receiver, QEvent *event)
|
||||
QScopedScopeLevelCounter scopeLevelCounter(threadData);
|
||||
if (!selfRequired)
|
||||
return doNotify(receiver, event);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0)
|
||||
if (threadData->thread.loadRelaxed() != QCoreApplicationPrivate::mainThread())
|
||||
return false;
|
||||
#endif
|
||||
return self->notify(receiver, event);
|
||||
}
|
||||
|
||||
@ -1181,7 +1186,7 @@ bool QCoreApplication::forwardEvent(QObject *receiver, QEvent *event, QEvent *or
|
||||
\endlist
|
||||
|
||||
\b{Future direction:} This function will not be called for objects that live
|
||||
outside the main thread in Qt 6. Applications that need that functionality
|
||||
outside the main thread in Qt 7. Applications that need that functionality
|
||||
should find other solutions for their event inspection needs in the meantime.
|
||||
The change may be extended to the main thread, causing this function to be
|
||||
deprecated.
|
||||
@ -1199,6 +1204,11 @@ bool QCoreApplication::notify(QObject *receiver, QEvent *event)
|
||||
Q_ASSERT(receiver);
|
||||
Q_ASSERT(event);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(7, 0, 0)
|
||||
Q_ASSERT(receiver->d_func()->threadData.loadAcquire()->thread.loadRelaxed()
|
||||
== QCoreApplicationPrivate::mainThread());
|
||||
#endif
|
||||
|
||||
// no events are delivered after ~QCoreApplication() has started
|
||||
if (QCoreApplicationPrivate::is_app_closing)
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user