diff options
author | Vitaly Fanaskov <vitaly.fanaskov@qt.io> | 2020-04-14 12:51:14 +0200 |
---|---|---|
committer | Vitaly Fanaskov <vitaly.fanaskov@qt.io> | 2020-04-23 17:09:52 +0200 |
commit | 9ba0715f08a64758453b941c4add22a269a30f71 (patch) | |
tree | fb99f735af3ed5e020317bdfb4f6866720722e43 /src/corelib/thread | |
parent | 23b998fa454ca021aa595f66d2e1964da4a119a4 (diff) |
QFuture: the result type doesn't have to be a default-constructible
Added asserts to insure the invariant declared in the documentation.
Canceled future object is not valid, hence we don't need to handle
this case separately.
Fixes: QTBUG-83389
Change-Id: Ib0653ef40cd3135574a91740e4ce2c6dc4da8a71
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qfutureinterface.h | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index 04828609ba..02f854e0de 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -339,13 +339,8 @@ inline QList<T> QFutureInterface<T>::results() template<typename T> T QFutureInterface<T>::takeResult() { - if (isCanceled()) { - exceptionStore().throwPossibleException(); - return {}; - } + Q_ASSERT(isValid()); - if (!isValid()) - return {}; // Note: we wait for all, this is intentional, // not to mess with other unready results. waitForResult(-1); @@ -362,13 +357,7 @@ T QFutureInterface<T>::takeResult() template<typename T> std::vector<T> QFutureInterface<T>::takeResults() { - if (isCanceled()) { - exceptionStore().throwPossibleException(); - return {}; - } - - if (!isValid()) - return {}; + Q_ASSERT(isValid()); waitForResult(-1); std::vector<T> res; |