From eb5cae26a43beae747909777da3f29fad82fef5e Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Wed, 27 Oct 2021 09:03:53 +0200 Subject: Add warning about QCoreApplication deferred delete MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some bug reports we got code which does deleteLater() on QCoreApplication, however this is not going to work as the user may expect. In cases where an application uses Qt WebEngine, this leads to weird looking crashes on exit as webenginecontext is not destroyed. Pick-to: 6.2 5.15 Change-Id: I4d284f30b0c7cad15ba6da3d65cdf813c36ee036 Reviewed-by: Michael BrĂ¼ning Reviewed-by: Allan Sandfeld Jensen --- src/corelib/kernel/qobject.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index ec4da51ad9..d4b345c2d4 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2313,6 +2313,10 @@ void QObject::removeEventFilter(QObject *obj) */ void QObject::deleteLater() { +#ifdef QT_DEBUG + if (qApp == this) + qWarning("You are deferring the delete of QCoreApplication, this may not work as expected."); +#endif QCoreApplication::postEvent(this, new QDeferredDeleteEvent()); } -- cgit v1.2.3