From b17284ee7d674416e0d11f1699f73fcc606262d4 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Tue, 16 Aug 2022 21:00:15 +0200 Subject: Introduce QXmppTask & QXmppPromise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #502. Co-authored-by: Jonah BrĂ¼chert --- src/client/QXmppHttpUploadManager.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/client/QXmppHttpUploadManager.cpp') diff --git a/src/client/QXmppHttpUploadManager.cpp b/src/client/QXmppHttpUploadManager.cpp index 2fe2994e..35eedf80 100644 --- a/src/client/QXmppHttpUploadManager.cpp +++ b/src/client/QXmppHttpUploadManager.cpp @@ -5,8 +5,8 @@ #include "QXmppHttpUploadManager.h" #include "QXmppClient.h" -#include "QXmppFutureUtils_p.h" #include "QXmppHttpUploadIq.h" +#include "QXmppTask.h" #include "QXmppUploadRequestManager.h" #include "QXmppUtils_p.h" @@ -299,11 +299,8 @@ std::shared_ptr QXmppHttpUploadManager::uploadFile(std::unique_ } auto future = client()->findExtension()->requestSlot(filename, fileSize, mimeType, uploadServiceJid); -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - await(future, this, [this, upload, data = std::move(data)](SlotResult result) mutable { -#else - await(future, this, [this, upload, rawSourceDevice = data.release()](SlotResult result) mutable { -#endif + // TODO: rawSourceDevice: could this lead to a memory leak if the "then lambda" is never executed? + future.then(this, [this, upload, rawSourceDevice = data.release()](SlotResult result) mutable { // first check whether upload was cancelled in the meantime if (upload->d->cancelled) { upload->d->reportFinished(); @@ -331,11 +328,6 @@ std::shared_ptr QXmppHttpUploadManager::uploadFile(std::unique_ request.setRawHeader(itr.key().toUtf8(), itr.value().toUtf8()); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - auto *rawSourceDevice = data.release(); -#else - // already defined in lambda capture -#endif auto *reply = d->netManager->put(request, rawSourceDevice); rawSourceDevice->setParent(reply); upload->d->reply = reply; -- cgit v1.2.3