aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/ftw
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-01-03 16:50:28 +0100
committerUlf Hermann <ulf.hermann@qt.io>2024-01-10 11:22:48 +0100
commit3bc2ac3db8b400c1171a8387982af5daee2cdcc6 (patch)
tree8ef2982ab805b4258172a3650c97ba1c0a87ee0f /src/qml/qml/ftw
parent47ddbb72e052989622f5fa23e032c787bed5f2e5 (diff)
QtQml: When clearing the type loader, also clear any pending events
The events typically hold references to the data blobs they want to notify about. Those will prevent such blobs from getting cleaned up. Since we are explicitly asked to clear everything, we should also clear those. Change-Id: I476b071d78555a561396181128f2e915df13aeee Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/ftw')
-rw-r--r--src/qml/qml/ftw/qqmlthread.cpp17
-rw-r--r--src/qml/qml/ftw/qqmlthread_p.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp
index 8589402bff..2aa8a57050 100644
--- a/src/qml/qml/ftw/qqmlthread.cpp
+++ b/src/qml/qml/ftw/qqmlthread.cpp
@@ -399,5 +399,22 @@ void QQmlThread::waitForNextMessage()
d->m_mainThreadWaiting = false;
}
+/*!
+ \internal
+ \note This method must be called in the main thread
+ \warning This method requires that the lock is held!
+
+ Clear all pending events, for either thread.
+*/
+void QQmlThread::discardMessages()
+{
+ Q_ASSERT(!isThisThread());
+ if (Message *mainSync = std::exchange(d->mainSync, nullptr))
+ delete mainSync;
+ while (!d->mainList.isEmpty())
+ delete d->mainList.takeFirst();
+ while (!d->threadList.isEmpty())
+ delete d->threadList.takeFirst();
+}
QT_END_NAMESPACE
diff --git a/src/qml/qml/ftw/qqmlthread_p.h b/src/qml/qml/ftw/qqmlthread_p.h
index 4af94036b5..35f586f7e7 100644
--- a/src/qml/qml/ftw/qqmlthread_p.h
+++ b/src/qml/qml/ftw/qqmlthread_p.h
@@ -64,6 +64,7 @@ public:
void postMethodToMain(Method &&method, Args &&...args);
void waitForNextMessage();
+ void discardMessages();
private:
friend class QQmlThreadPrivate;