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>
This commit is contained in:
parent
9b4b32ec98
commit
028c367f75
@ -522,15 +522,18 @@ QFuture<std::variant<std::decay_t<Futures>...>> whenAny(Futures &&... futures);
|
|||||||
|
|
||||||
#endif // Q_QDOC
|
#endif // Q_QDOC
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 10)
|
||||||
#if defined(Q_QDOC)
|
#if defined(Q_QDOC)
|
||||||
static QFuture<void> makeReadyFuture()
|
static QFuture<void> makeReadyFuture()
|
||||||
#else
|
#else
|
||||||
template<typename T = void>
|
template<typename T = void>
|
||||||
|
QT_DEPRECATED_VERSION_X(6, 10, "Use makeReadyVoidFuture() instead")
|
||||||
static QFuture<T> makeReadyFuture()
|
static QFuture<T> makeReadyFuture()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
return makeReadyVoidFuture();
|
return makeReadyVoidFuture();
|
||||||
}
|
}
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 10)
|
||||||
|
|
||||||
} // namespace QtFuture
|
} // namespace QtFuture
|
||||||
|
|
||||||
|
@ -973,6 +973,12 @@
|
|||||||
|
|
||||||
\since 6.1
|
\since 6.1
|
||||||
\overload
|
\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.
|
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.
|
The returned QFuture has a type of std::decay_t<T>, where T is not void.
|
||||||
@ -992,6 +998,12 @@
|
|||||||
|
|
||||||
\since 6.1
|
\since 6.1
|
||||||
\overload
|
\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.
|
Creates and returns a void QFuture. Such QFuture can't store any result.
|
||||||
One can use it to query the state of the computation.
|
One can use it to query the state of the computation.
|
||||||
@ -1015,6 +1027,12 @@
|
|||||||
|
|
||||||
\since 6.1
|
\since 6.1
|
||||||
\overload
|
\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.
|
Creates and returns a QFuture which already has multiple results set from \a values.
|
||||||
|
|
||||||
|
@ -1009,7 +1009,9 @@ static QFuture<std::decay_t<T>> makeReadyValueFuture(T &&value)
|
|||||||
|
|
||||||
Q_CORE_EXPORT QFuture<void> makeReadyVoidFuture(); // implemented in qfutureinterface.cpp
|
Q_CORE_EXPORT QFuture<void> makeReadyVoidFuture(); // implemented in qfutureinterface.cpp
|
||||||
|
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 10)
|
||||||
template<typename T, typename = QtPrivate::EnableForNonVoid<T>>
|
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)
|
static QFuture<std::decay_t<T>> makeReadyFuture(T &&value)
|
||||||
{
|
{
|
||||||
return makeReadyValueFuture(std::forward<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.
|
// uses makeReadyVoidFuture() and required QFuture<void> to be defined.
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
QT_DEPRECATED_VERSION_X(6, 10, "Use makeReadyRangeFuture() instead")
|
||||||
static QFuture<T> makeReadyFuture(const QList<T> &values)
|
static QFuture<T> makeReadyFuture(const QList<T> &values)
|
||||||
{
|
{
|
||||||
return makeReadyRangeFuture(values);
|
return makeReadyRangeFuture(values);
|
||||||
}
|
}
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 10)
|
||||||
|
|
||||||
#ifndef QT_NO_EXCEPTIONS
|
#ifndef QT_NO_EXCEPTIONS
|
||||||
|
|
||||||
|
@ -4078,6 +4078,9 @@ void tst_QFuture::rejectPendingResultOverwrite()
|
|||||||
|
|
||||||
void tst_QFuture::createReadyFutures()
|
void tst_QFuture::createReadyFutures()
|
||||||
{
|
{
|
||||||
|
#if QT_DEPRECATED_SINCE(6, 10)
|
||||||
|
QT_WARNING_PUSH
|
||||||
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
// using const T &
|
// using const T &
|
||||||
{
|
{
|
||||||
const int val = 42;
|
const int val = 42;
|
||||||
@ -4113,6 +4116,8 @@ void tst_QFuture::createReadyFutures()
|
|||||||
QCOMPARE(f.resultCount(), 3);
|
QCOMPARE(f.resultCount(), 3);
|
||||||
QCOMPARE(f.results(), values);
|
QCOMPARE(f.results(), values);
|
||||||
}
|
}
|
||||||
|
QT_WARNING_POP
|
||||||
|
#endif // QT_DEPRECATED_SINCE(6, 10)
|
||||||
|
|
||||||
// test makeReadyValueFuture<T>()
|
// test makeReadyValueFuture<T>()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user