summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcoreapplication.cpp
diff options
context:
space:
mode:
authorDheerendra Purohit <[email protected]>2025-07-05 12:47:39 +0530
committerDheerendra Purohit <[email protected]>2025-07-12 18:30:13 +0530
commit50f1288946cae0ad8a66d5003fc4bb8138d9b6dd (patch)
treeb706527e2c8248fb75118d0a5a90c687d9b66fd0 /src/corelib/kernel/qcoreapplication.cpp
parentff5351b12f4dd6de1a96728859456aac556272af (diff)
Doc: Improve guidance on deleteLater() usage in threadsHEADdev
Add example of QThread::finished or deleteLater in QObject docs. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-94939 Change-Id: I385aef86f88a4bb92d3d647468bbbe94225010e2 Reviewed-by: Thiago Macieira <[email protected]>
Diffstat (limited to 'src/corelib/kernel/qcoreapplication.cpp')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 1b711ba16bd..55d9cea7c6c 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1618,6 +1618,17 @@ QCoreApplicationPrivate::QPostEventListLocker QCoreApplicationPrivate::lockThrea
details. Events with equal \a priority will be processed in the
order posted.
+ \note QObject::deleteLater() schedules the object for deferred
+ deletion, which is typically handled by the receiver's event
+ loop. If no event loop is running in the thread, the deletion
+ will be performed when the thread finishes. A common and safe
+ pattern is to connect the thread's finished() signal to the
+ object's deleteLater() slot:
+
+ \code
+ QObject::connect(thread, &QThread::finished, worker, &QObject::deleteLater);
+ \endcode
+
\threadsafe
\sa sendEvent(), notify(), sendPostedEvents(), Qt::EventPriority