diff options
author | Ivan Solovev <ivan.solovev@qt.io> | 2023-03-20 16:57:27 +0100 |
---|---|---|
committer | Ivan Solovev <ivan.solovev@qt.io> | 2023-04-05 13:38:15 +0200 |
commit | 028c367f757b98008bb9209252e5617758c88e0a (patch) | |
tree | 528e3de4ccca38286b6b06a4ac9a0c2bbbd5b14b | |
parent | 9b4b32ec98bf80023d2233a061564dfe59b783c7 (diff) |
Deprecate QtFuture::makeReadyFuture()
[ChangeLog][Deprecation Notice][QtCore] The QtFuture::makeReadyFuture()
method and all its specializations are deprecated since Qt 6.10.
The reason for the deprecation is that the method has a
makeReadyFuture(const QList<T> &) overload, which behaves differently
from all other overloads (including other non-const ref QList
overloads).
Use QtFuture::makeReadyVoidFuture() when you need a ready void QFuture,
or QtFuture::makeReadyValueFuture() when you need to propagate the
input type to the returned QFuture, or QtFuture::makeReadyRangeFuture()
when you need to create a multi-value future based on an input
container.
Fixes: QTBUG-109677
Change-Id: I55125269989df0a02840d5ddd5763ef5f1070df5
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
-rw-r--r-- | src/corelib/thread/qfuture.h | 3 | ||||
-rw-r--r-- | src/corelib/thread/qfuture.qdoc | 18 | ||||
-rw-r--r-- | src/corelib/thread/qfuture_impl.h | 4 | ||||
-rw-r--r-- | tests/auto/corelib/thread/qfuture/tst_qfuture.cpp | 5 |
4 files changed, 30 insertions, 0 deletions
diff --git a/src/corelib/thread/qfuture.h b/src/corelib/thread/qfuture.h index 219d3368f0..572c8054f9 100644 --- a/src/corelib/thread/qfuture.h +++ b/src/corelib/thread/qfuture.h @@ -522,15 +522,18 @@ QFuture<std::variant<std::decay_t<Futures>...>> whenAny(Futures &&... futures); #endif // Q_QDOC +#if QT_DEPRECATED_SINCE(6, 10) #if defined(Q_QDOC) static QFuture<void> makeReadyFuture() #else template<typename T = void> +QT_DEPRECATED_VERSION_X(6, 10, "Use makeReadyVoidFuture() instead") static QFuture<T> makeReadyFuture() #endif { return makeReadyVoidFuture(); } +#endif // QT_DEPRECATED_SINCE(6, 10) } // namespace QtFuture diff --git a/src/corelib/thread/qfuture.qdoc b/src/corelib/thread/qfuture.qdoc index e9aabdda2d..7d0f639417 100644 --- a/src/corelib/thread/qfuture.qdoc +++ b/src/corelib/thread/qfuture.qdoc @@ -973,6 +973,12 @@ \since 6.1 \overload + \deprecated [6.10] Use makeReadyValueFuture() instead + + The QtFuture::makeReadyFuture() method should be avoided because it has an + inconsistent set of overloads. It will be deprecated in future Qt releases. + Use QtFuture::makeReadyVoidFuture(), QtFuture::makeReadyValueFuture() or + QtFuture::makeReadyRangeFuture() instead. Creates and returns a QFuture which already has a result \a value. The returned QFuture has a type of std::decay_t<T>, where T is not void. @@ -992,6 +998,12 @@ \since 6.1 \overload + \deprecated [6.10] Use makeReadyVoidFuture() instead + + The QtFuture::makeReadyFuture() method should be avoided because it has an + inconsistent set of overloads. It will be deprecated in future Qt releases. + Use QtFuture::makeReadyVoidFuture(), QtFuture::makeReadyValueFuture() or + QtFuture::makeReadyRangeFuture() instead. Creates and returns a void QFuture. Such QFuture can't store any result. One can use it to query the state of the computation. @@ -1015,6 +1027,12 @@ \since 6.1 \overload + \deprecated [6.10] Use makeReadyRangeFuture() instead + + The QtFuture::makeReadyFuture() method should be avoided because it has an + inconsistent set of overloads. It will be deprecated in future Qt releases. + Use QtFuture::makeReadyVoidFuture(), QtFuture::makeReadyValueFuture() or + QtFuture::makeReadyRangeFuture() instead. Creates and returns a QFuture which already has multiple results set from \a values. diff --git a/src/corelib/thread/qfuture_impl.h b/src/corelib/thread/qfuture_impl.h index b282903405..47a07801c7 100644 --- a/src/corelib/thread/qfuture_impl.h +++ b/src/corelib/thread/qfuture_impl.h @@ -1009,7 +1009,9 @@ static QFuture<std::decay_t<T>> makeReadyValueFuture(T &&value) Q_CORE_EXPORT QFuture<void> makeReadyVoidFuture(); // implemented in qfutureinterface.cpp +#if QT_DEPRECATED_SINCE(6, 10) template<typename T, typename = QtPrivate::EnableForNonVoid<T>> +QT_DEPRECATED_VERSION_X(6, 10, "Use makeReadyValueFuture() instead") static QFuture<std::decay_t<T>> makeReadyFuture(T &&value) { return makeReadyValueFuture(std::forward<T>(value)); @@ -1019,10 +1021,12 @@ static QFuture<std::decay_t<T>> makeReadyFuture(T &&value) // uses makeReadyVoidFuture() and required QFuture<void> to be defined. template<typename T> +QT_DEPRECATED_VERSION_X(6, 10, "Use makeReadyRangeFuture() instead") static QFuture<T> makeReadyFuture(const QList<T> &values) { return makeReadyRangeFuture(values); } +#endif // QT_DEPRECATED_SINCE(6, 10) #ifndef QT_NO_EXCEPTIONS diff --git a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp index bb78898836..118a005de5 100644 --- a/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp +++ b/tests/auto/corelib/thread/qfuture/tst_qfuture.cpp @@ -4078,6 +4078,9 @@ void tst_QFuture::rejectPendingResultOverwrite() void tst_QFuture::createReadyFutures() { +#if QT_DEPRECATED_SINCE(6, 10) +QT_WARNING_PUSH +QT_WARNING_DISABLE_DEPRECATED // using const T & { const int val = 42; @@ -4113,6 +4116,8 @@ void tst_QFuture::createReadyFutures() QCOMPARE(f.resultCount(), 3); QCOMPARE(f.results(), values); } +QT_WARNING_POP +#endif // QT_DEPRECATED_SINCE(6, 10) // test makeReadyValueFuture<T>() { |