QFuture then continuation never finishes
Unsolved
Qt 6
-
Hello, I have a question about QFuture and their continuation
then
API. Consider the following example code:auto future = getAccountToken("test@mailprovider.com", "password") .then([this](QFuture<QString> f) { auto const token = f.result(); return getGameAccounts(token); }) .then([this](QFuture<QList<GameAccount>> f) { auto const gameAccounts = f.result(); // --> LINE NEVER REACHED (WAITS FOREVER ON f.result() CALL) });
And:
QFuture<QString> getAccountToken(/*...*/) { QPromise<QString> promise; auto future = promise.future(); promise.start(); QNetworkRequest request(QUrl("https://example.org")); // ... auto reply = networkMngr->post(request, doc.toJson()); connect(reply, &QNetworkReply::finished, [reply, p = std::move(promise)]() mutable { p.addResult("<TOKEN FROM REPLY>"); p.finish(); reply->deleteLater(); }); return future; }
The function
getGameAccounts
has the same boilerplate code asgetAccountToken
, except that it performs a GET request instead.
Does anyone know why I never reach the line afterauto const gameAccounts = f.result();
? A single.then
continuation works fine.
FYI: I don't reach theconnect
lambda for the reply ingetGameAccounts
either, which explains why I never have any result. But I can't seem to figure out why that happens.Thank you in advance.