summaryrefslogtreecommitdiffstats
path: root/src/concurrent
diff options
context:
space:
mode:
authorTianlu Shao <shaotianlu@uniontech.com>2021-12-17 10:27:55 +0800
committerSona Kurazyan <sona.kurazyan@qt.io>2021-12-20 13:18:26 +0100
commit87b93c29be02f0a7ff9424b5e2b6431e20bd4c40 (patch)
tree8063deab75bed4e1f420d669b734f7823847fee1 /src/concurrent
parent43e9f86cc15fe5b394ee1690b302104118572fe1 (diff)
QtConcurrent::run crashes on program exit
When an application is about to be closed and all the destructors are called, if there isQtConcurrent::run on the way, it crashes as the internal threadpool pointer is nullptr. Fixes: QTBUG-98901 Pick-to: 6.2 6.3 Change-Id: Idd84d1518fc6a225263e6666a0f1de2ccef79c82 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'src/concurrent')
-rw-r--r--src/concurrent/qtconcurrentrunbase.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/concurrent/qtconcurrentrunbase.h b/src/concurrent/qtconcurrentrunbase.h
index 6038d0e60c..4870362146 100644
--- a/src/concurrent/qtconcurrentrunbase.h
+++ b/src/concurrent/qtconcurrentrunbase.h
@@ -93,7 +93,13 @@ public:
promise.setRunnable(this);
promise.reportStarted();
QFuture<T> theFuture = promise.future();
- parameters.threadPool->start(this, parameters.priority);
+
+ if (parameters.threadPool) {
+ parameters.threadPool->start(this, parameters.priority);
+ } else {
+ promise.reportCanceled();
+ promise.reportFinished();
+ }
return theFuture;
}