aboutsummaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2021-12-05 15:39:39 +0100
committerLinus Jahn <lnj@kaidan.im>2022-03-03 12:19:39 +0100
commit30fb4de15cfb4586bba0f7f379011e46298941f4 (patch)
tree5fe5ff271234c8b8ed070a416d4ce3da612b3bfc /src/base
parent568b7db65d6017b53c735a8507124a567e9dacbe (diff)
downloadqxmpp-30fb4de15cfb4586bba0f7f379011e46298941f4.tar.gz
FutureUtils: chain: Use future interface without shared_ptr
Didn't work before because the lambdas weren't mutable and so the QFutureInterface was always const.
Diffstat (limited to 'src/base')
-rw-r--r--src/base/QXmppFutureUtils_p.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/base/QXmppFutureUtils_p.h b/src/base/QXmppFutureUtils_p.h
index 801ae285..c4b00e13 100644
--- a/src/base/QXmppFutureUtils_p.h
+++ b/src/base/QXmppFutureUtils_p.h
@@ -106,16 +106,16 @@ void await(const QFuture<void> &future, QObject *context, Handler handler)
template<typename Result, typename Input, typename Converter>
auto chain(QFuture<Input> &&source, QObject *context, Converter task) -> QFuture<Result>
{
- auto resultInterface = std::make_shared<QFutureInterface<Result>>(QFutureInterfaceBase::Started);
+ QFutureInterface<Result> resultInterface(QFutureInterfaceBase::Started);
auto *watcher = new QFutureWatcher<Input>(context);
- QObject::connect(watcher, &QFutureWatcherBase::finished, context, [=]() {
- resultInterface->reportResult(task(watcher->result()));
- resultInterface->reportFinished();
+ QObject::connect(watcher, &QFutureWatcherBase::finished, context, [=]() mutable {
+ resultInterface.reportResult(task(watcher->result()));
+ resultInterface.reportFinished();
watcher->deleteLater();
});
watcher->setFuture(source);
- return resultInterface->future();
+ return resultInterface.future();
}
template<typename IqType, typename Input, typename Converter>