summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qfuture_impl.h
diff options
context:
space:
mode:
authorArno Rehn <a.rehn@menlosystems.com>2023-06-15 17:12:02 +0200
committerArno Rehn <a.rehn@menlosystems.com>2023-06-20 09:35:15 +0200
commit855c4484693015cb6498f2183d95de1377d49898 (patch)
tree853302d072fe65a695b5e72f4df0f8e1131f7ed7 /src/corelib/thread/qfuture_impl.h
parent1f6cac0da9c31b67f5cb5850ce52a4622e57b4d5 (diff)
QPromise: Propagate cancellation through failure handlers
Previously, failure handlers did not propagate cancellation. This would lead to crashes when a QPromise was cancelled without having generated any result. Subsequent continuations would be invoked and try to access the result (which was nonexistent) and then crash. This patch propagates cancellation through failure handlers to prevent subsequent continuations from being called in the first place. Fixes: QTBUG-114606 Pick-to: 6.6 Pick-to: 6.5 Change-Id: I23b28a8e70a76e1ba6416be4440360c6dbaef2a3 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/thread/qfuture_impl.h')
-rw-r--r--src/corelib/thread/qfuture_impl.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/thread/qfuture_impl.h b/src/corelib/thread/qfuture_impl.h
index 53f2326cde..5b4c929a36 100644
--- a/src/corelib/thread/qfuture_impl.h
+++ b/src/corelib/thread/qfuture_impl.h
@@ -732,6 +732,8 @@ void FailureHandler<Function, ResultType>::run()
} else {
handleException<ArgType>();
}
+ } else if (parentFuture.d.isChainCanceled()) {
+ promise.future().cancel();
} else {
QtPrivate::fulfillPromise(promise, parentFuture);
}