aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-05-31 17:09:16 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-09-07 13:23:44 +0000
commit7429f6f366172bf2e1e3c97cc3ebbc4be61b0cde (patch)
tree0cf88e16f903ee797d35a9f7a0284962d0b8343c
parentee295affc6210cb71a242f7e119e7a4f95b75fc3 (diff)
Fix workflow for shutting down busy type loader threads
We need to set the shutdown flag right away in order to prevent further thread events from getting scheduled. Those might lead to deadlocks. On the loader thread's side, however, we need to process the existing events before we process the shutdown flag, in order not to leak the events. After we are done with this routine, the thread will finish by itself. We don't need to wait on our mutex anymore. It's enough to wait on the thread itself. Task-number: QTBUG-75777 Change-Id: Id0afcb492d84617c78ff3bf94d0cc402aef2faa4 (cherry-picked from commit 0521b55f201299ee9f031f61d5bf8f2be18cf8c5) Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Igor Kushnir <igorkuo@gmail.com>
-rw-r--r--src/qml/qml/ftw/qqmlthread.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/qml/qml/ftw/qqmlthread.cpp b/src/qml/qml/ftw/qqmlthread.cpp
index 7d2ad354d6..0f7726ef65 100644
--- a/src/qml/qml/ftw/qqmlthread.cpp
+++ b/src/qml/qml/ftw/qqmlthread.cpp
@@ -188,13 +188,7 @@ void QQmlThreadPrivate::threadEvent()
lock();
for (;;) {
- if (m_shutdown) {
- quit();
- wakeOne();
- unlock();
-
- return;
- } else if (!threadList.isEmpty()) {
+ if (!threadList.isEmpty()) {
m_threadProcessing = true;
QQmlThread::Message *message = threadList.first();
@@ -206,6 +200,12 @@ void QQmlThreadPrivate::threadEvent()
lock();
delete threadList.takeFirst();
+ } else if (m_shutdown) {
+ quit();
+ wakeOne();
+ unlock();
+
+ return;
} else {
wakeOne();
@@ -242,6 +242,7 @@ void QQmlThread::shutdown()
d->lock();
Q_ASSERT(!d->m_shutdown);
+ d->m_shutdown = true;
for (;;) {
if (d->mainSync || !d->mainList.isEmpty()) {
d->unlock();
@@ -254,13 +255,10 @@ void QQmlThread::shutdown()
}
}
- d->m_shutdown = true;
- if (QCoreApplication::closingDown()) {
+ if (QCoreApplication::closingDown())
d->quit();
- } else {
+ else
d->triggerThreadEvent();
- d->wait();
- }
d->unlock();
d->QThread::wait();