From 642b9fce81b46e23b35b17e8284bd81bdba57fdd Mon Sep 17 00:00:00 2001 From: Sona Kurazyan Date: Tue, 17 Aug 2021 16:00:26 +0200 Subject: QtConcurrent::run: support non default-constructible return types The QtConcurrent::RunFunctionTask class keeps a variable to store the result of QtConcurrent::run when it becomes available, so that it can be reported afterwards. This requires the result type to be default-constructible. However there's no need in storing the result, it can be reported immediately after it becomes available. Pick-to: 6.1 6.2 Fixes: QTBUG-95214 Change-Id: I95f3dbff0ab41eaa81b104a8834b37d10a0d193a Reviewed-by: Jarek Kobus Reviewed-by: Andrei Golubev --- tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto/corelib/thread') diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp index 929047c07e..33ecfb9cab 100644 --- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp @@ -229,12 +229,12 @@ void tst_QFutureWatcher::canceled() future.waitForFinished(); } -class IntTask : public RunFunctionTask +class IntTask : public RunFunctionTaskBase { public: void runFunctor() override { - result = 10; + promise.reportResult(10); } }; @@ -463,7 +463,7 @@ void tst_QFutureWatcher::disconnectRunningFuture() } const int maxProgress = 100000; -class ProgressEmitterTask : public RunFunctionTask +class ProgressEmitterTask : public RunFunctionTaskBase { public: void runFunctor() override @@ -493,7 +493,7 @@ void tst_QFutureWatcher::tooMuchProgress() } template -class ProgressTextTask : public RunFunctionTask +class ProgressTextTask : public RunFunctionTaskBase { public: void runFunctor() override -- cgit v1.2.3