From 3164746eb09a34818cfa874ae248d01e0c4f5d74 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Tue, 28 Jan 2025 15:20:28 +0100 Subject: [PATCH] QFutureInterface: mark the unused setContinuation() overloads as removed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a cleanup after the previous patch that introduced the new setContinuation() overloads. The old API cannot be used correctly with the new approach that requires to always set a continuation type, so let's mark it as removed. Technically, this change is SiC. However, QFutureInterfaceBase was never documented as a public class, so users are not supposed to derive from it and should not use setContinuation() methods directly. Task-number: QTBUG-130662 Change-Id: Idf3d9f5de00a7c4ac34ee3dde1d58902e3a27904 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/compat/removed_api.cpp | 40 +++++++++++++++++++++++++ src/corelib/thread/qfutureinterface.cpp | 34 --------------------- src/corelib/thread/qfutureinterface.h | 7 +++++ 3 files changed, 47 insertions(+), 34 deletions(-) diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index 1db1401f0e7..9efef0b958a 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -1380,6 +1380,46 @@ QUuid::Version QUuid::version() const noexcept #if QT_CORE_REMOVED_SINCE(6, 10) +#if QT_CONFIG(future) +#include "qfuture.h" // for ContinuationWrapper +#include "qfutureinterface.h" + +void QtPrivate::watchContinuationImpl(const QObject *context, + QtPrivate::QSlotObjectBase *slotObj, + QFutureInterfaceBase &fi) +{ + Q_ASSERT(context); + Q_ASSERT(slotObj); + + auto slot = QtPrivate::SlotObjUniquePtr(slotObj); + + // That is now a double-inderection, because the setContinuation() overload + // also uses QSlotObjectBase approach. But that's a solution for backwards + // compatibility, so should be fine. + // We pass a default-constructed QVariant() and an Unknown type, because + // that's effectively the same as passing a nullptr continuationData, and + // that's what the old code was doing. + fi.setContinuation(context, QtPrivate::ContinuationWrapper([slot = std::move(slot)]() + { + void *args[] = { nullptr }; // for `void` return value + slot->call(nullptr, args); + }), QVariant(), QFutureInterfaceBase::ContinuationType::Unknown); +} + +void QFutureInterfaceBase::setContinuation(std::function func) +{ + setContinuation(std::move(func), nullptr); +} + +void QFutureInterfaceBase::setContinuation(std::function func, + QFutureInterfaceBasePrivate *continuationFutureData) +{ + // Backwards compatibility - the continuation data was used for + // then-continuations + setContinuation(std::move(func), continuationFutureData, ContinuationType::Then); +} +#endif // QT_CONFIG(future) + #include "qlogging.h" QNoDebug QMessageLogger::noDebug() const noexcept diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index 3252a0def54..cc61752f28d 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -55,27 +55,6 @@ signals: void run(); }; -void QtPrivate::watchContinuationImpl(const QObject *context, QSlotObjectBase *slotObj, - QFutureInterfaceBase &fi) -{ - Q_ASSERT(context); - Q_ASSERT(slotObj); - - auto slot = SlotObjUniquePtr(slotObj); - - // That is now a double-inderection, because the setContinuation() overload - // also uses QSlotObjectBase approach. But that's a solution for backwards - // compatibility, so should be fine. - // We pass a default-constructed QVariant() and an Unknown type, because - // that's effectively the same as passing a nullptr continuationData, and - // that's what the old code was doing. - fi.setContinuation(context, ContinuationWrapper([slot = std::move(slot)]() - { - void *args[] = { nullptr }; // for `void` return value - slot->call(nullptr, args); - }), QVariant(), QFutureInterfaceBase::ContinuationType::Unknown); -} - QFutureCallOutInterface::~QFutureCallOutInterface() = default; @@ -846,19 +825,6 @@ void QFutureInterfaceBasePrivate::setState(QFutureInterfaceBase::State newState) state.storeRelaxed(newState); } -void QFutureInterfaceBase::setContinuation(std::function func) -{ - setContinuation(std::move(func), nullptr); -} - -void QFutureInterfaceBase::setContinuation(std::function func, - QFutureInterfaceBasePrivate *continuationFutureData) -{ - // Backwards compatibility - the continuation data was used for - // then-continuations - setContinuation(std::move(func), continuationFutureData, ContinuationType::Then); -} - void QFutureInterfaceBase::setContinuation(std::function func, void *continuationFutureData, ContinuationType type) { diff --git a/src/corelib/thread/qfutureinterface.h b/src/corelib/thread/qfutureinterface.h index 2c25473f799..e3d0332f6f0 100644 --- a/src/corelib/thread/qfutureinterface.h +++ b/src/corelib/thread/qfutureinterface.h @@ -6,6 +6,7 @@ #include #include +#include #ifndef QT_NO_EXCEPTIONS #include #endif @@ -40,9 +41,11 @@ template class FailureHandler; #endif +#if QT_CORE_REMOVED_SINCE(6, 10) void Q_CORE_EXPORT watchContinuationImpl(const QObject *context, QtPrivate::QSlotObjectBase *slotObj, QFutureInterfaceBase &fi); +#endif // QT_CORE_REMOVED_SINCE(6, 10) } class Q_CORE_EXPORT QFutureInterfaceBase @@ -182,8 +185,10 @@ private: friend class QtPrivate::FailureHandler; #endif +#if QT_CORE_REMOVED_SINCE(6, 10) friend Q_CORE_EXPORT void QtPrivate::watchContinuationImpl( const QObject *context, QtPrivate::QSlotObjectBase *slotObj, QFutureInterfaceBase &fi); +#endif // QT_CORE_REMOVED_SINCE(6, 10) template friend class QPromise; @@ -197,9 +202,11 @@ protected: OnCanceled, }; +#if QT_CORE_REMOVED_SINCE(6, 10) void setContinuation(std::function func); void setContinuation(std::function func, QFutureInterfaceBasePrivate *continuationFutureData); +#endif // QT_CORE_REMOVED_SINCE(6, 10) void setContinuation(std::function func, void *continuationFutureData, ContinuationType type); void setContinuation(const QObject *context, std::function func,