From c34673e5d918e1882401572f81d8c2d6f54c5459 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 30 Sep 2020 16:42:47 +0200 Subject: QtConcurrent: Handle running with promise inside QTaskBuilder Please note, that in case of run with promise it doesn't make sense to provide the overload taking the FutureResult, as if we are going to ignore the returned QFuture object, we can't communicate with the passed QPromise. Fixes: QTBUG-87083 Change-Id: I4066506736c2bbeea3e42030b9495f13e06cb27e Reviewed-by: Sona Kurazyan --- .../doc/snippets/code/src_concurrent_qtconcurrenttask.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/concurrent/doc/snippets/code') diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrenttask.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrenttask.cpp index b067b49e7e0..267d6ebc1ef 100644 --- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrenttask.cpp +++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrenttask.cpp @@ -129,3 +129,12 @@ QtConcurrent::task([]{ return 42; }).withPriority(10).spawn(); //! [11] QtConcurrent::task([]{ qDebug("Hello, world!"); }).spawn(FutureResult::Ignore); //! [11] + +//! [12] +void increment(QPromise &promise, int i) +{ + promise.addResult(i + 1); +} + +int result = QtConcurrent::task(&increment).withArguments(10).spawn().result(); // result == 11 +//! [12] -- cgit v1.2.3