TaskTree manual test: Use QPromise for async calls

Change-Id: I532520af644b431441d74c0e06eff4d06d0b3924
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2023-02-12 00:54:48 +01:00
parent 3e7d93c788
commit 00938bd7bf

View File

@@ -18,11 +18,11 @@
using namespace Utils;
// TODO: make tasks cancellable
static void sleepInThread(QFutureInterface<void> &fi, int seconds, bool reportSuccess)
static void sleepInThread(QPromise<void> &promise, int seconds, bool reportSuccess)
{
QThread::sleep(seconds);
if (!reportSuccess)
fi.reportCanceled();
promise.future().cancel();
}
int main(int argc, char *argv[])
@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
auto taskItem = [sync = &synchronizer, synchronizerCheckBox](TaskWidget *widget) {
const auto setupHandler = [=](AsyncTask<void> &task) {
task.setAsyncCallData(sleepInThread, widget->busyTime(), widget->isSuccess());
task.setConcurrentCallData(sleepInThread, widget->busyTime(), widget->isSuccess());
if (synchronizerCheckBox->isChecked())
task.setFutureSynchronizer(sync);
widget->setState(State::Running);