Mark QObject::deleteLater() as \threadsafe

Because it is. It's just QCoreApplication::postEvent(), which is thread-safe.

It also _has_ to be, because we recommend to use deleteLater() to delete
QObjects that live in another thread:

Quoting the ~QObject() docs:

> Warning: Deleting a QObject while pending events are waiting to be delivered
> 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 delivered to it.

If deleteLater() is not thread-safe, it cannot be used for one of its intended
purposes.

Change-Id: I333d506b42bdfcdff00fe6cefa234c21865625a6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Marc Mutz 2019-06-26 15:32:50 +02:00
parent fb35359226
commit 8d414e6794

View File

@ -2163,6 +2163,8 @@ void QObject::removeEventFilter(QObject *obj)
*/
/*!
\threadsafe
Schedules this object for deletion.
The object will be deleted when control returns to the event