diff --git a/quotest/quotest.cpp b/quotest/quotest.cpp index 9bbde3a8b..e0770718e 100644 --- a/quotest/quotest.cpp +++ b/quotest/quotest.cpp @@ -459,15 +459,26 @@ struct DownloadRunner { using result_type = QNetworkReply::NetworkError; - QNetworkReply::NetworkError operator()(int) const + void runRequest(QScopedPointer& r, + QEventLoop& el) const { - QEventLoop el; - QScopedPointer reply { - NetworkAccessManager::instance()->get(QNetworkRequest(url)) - }; + r.reset(NetworkAccessManager::instance()->get(QNetworkRequest(url))); QObject::connect( - reply.data(), &QNetworkReply::finished, &el, [&el] { el.exit(); }, + r.data(), &QNetworkReply::finished, &el, + [this, &r, &el] { + if (r->error() != QNetworkReply::NoError) + runRequest(r, el); + else + el.exit(); + }, Qt::QueuedConnection); + } + + QNetworkReply::NetworkError operator()(int) const + { + thread_local QEventLoop el; + thread_local QScopedPointer reply{}; + runRequest(reply, el); el.exec(); return reply->error(); }