QObject: fix a documentation note in the destructor

The docs for ~QObject say:

> any pending posted events for the object are removed from the event
> queue

but then they also say:

> Deleting a QObject while pending events are waiting to be delivered
> can cause a crash

These two contradict each other. In fact, the first one is correct, the
second one is factually incorrect. Amend it to what I believe it's the
intended meaning: do not destroy a QObject which is _handling_ an event
(i.e. we're into QObject::event() or an override).

Change-Id: Id1d564f296e17a764e0f49ebfedf6e292085c221
Pick-to: 6.6 6.5 6.2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Shantanu Tushar <shantanu.tushar@kdab.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 6e0c438a41a61a3d0a93954f00f46951c4399224)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2024-03-05 14:32:45 +01:00 committed by Qt Cherry-pick Bot
parent f148aa073e
commit 23d7faa8a1

View File

@ -1023,8 +1023,8 @@ void QObjectPrivate::clearBindingStorage()
outside the parent. If you still do, the destroyed() signal gives
you an opportunity to detect when an object is destroyed.
\warning Deleting a QObject while pending events are waiting to
be delivered can cause a crash. You must not delete the QObject
\warning Deleting a QObject while it is handling an event
delivered to it can cause a crash. You must not delete the QObject
directly if it exists in a different thread than the one currently
executing. Use deleteLater() instead, which will cause the event
loop to delete the object after all pending events have been