From 855c4484693015cb6498f2183d95de1377d49898 Mon Sep 17 00:00:00 2001 From: Arno Rehn Date: Thu, 15 Jun 2023 17:12:02 +0200 Subject: 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 --- src/corelib/thread/qfuture_impl.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/thread/qfuture_impl.h') 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::run() } else { handleException(); } + } else if (parentFuture.d.isChainCanceled()) { + promise.future().cancel(); } else { QtPrivate::fulfillPromise(promise, parentFuture); } -- cgit v1.2.3