diff options
Diffstat (limited to 'src/corelib/thread')
-rw-r--r-- | src/corelib/thread/qfuture_impl.h | 14 | ||||
-rw-r--r-- | src/corelib/thread/qfutureinterface.cpp | 2 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/corelib/thread/qfuture_impl.h b/src/corelib/thread/qfuture_impl.h index 69f57652ea..b09d84a6d3 100644 --- a/src/corelib/thread/qfuture_impl.h +++ b/src/corelib/thread/qfuture_impl.h @@ -538,11 +538,19 @@ bool Continuation<Function, ResultType, ParentResultType>::execute() template<class Function> struct ContinuationWrapper { - ContinuationWrapper(Function &&f) : function(QSharedPointer<Function>::create(std::move(f))) { } - void operator()(const QFutureInterfaceBase &parentData) { (*function)(parentData); } + ContinuationWrapper(Function &&f) : function(std::move(f)) { } + ContinuationWrapper(const ContinuationWrapper &other) + : function(std::move(const_cast<ContinuationWrapper &>(other).function)) + { + Q_ASSERT_X(false, "QFuture", "Continuation shouldn't be copied"); + } + ContinuationWrapper(ContinuationWrapper &&other) = default; + ContinuationWrapper &operator=(ContinuationWrapper &&) = default; + + void operator()(const QFutureInterfaceBase &parentData) { function(parentData); } private: - QSharedPointer<Function> function; + Function function; }; template<typename Function, typename ResultType, typename ParentResultType> diff --git a/src/corelib/thread/qfutureinterface.cpp b/src/corelib/thread/qfutureinterface.cpp index dfc905e828..cad6111ab9 100644 --- a/src/corelib/thread/qfutureinterface.cpp +++ b/src/corelib/thread/qfutureinterface.cpp @@ -837,7 +837,7 @@ void QFutureInterfaceBasePrivate::setState(QFutureInterfaceBase::State newState) void QFutureInterfaceBase::setContinuation(std::function<void(const QFutureInterfaceBase &)> func) { - setContinuation(func, nullptr); + setContinuation(std::move(func), nullptr); } void QFutureInterfaceBase::setContinuation(std::function<void(const QFutureInterfaceBase &)> func, |