From eaff0ddee73d8fa0569d06a79716bf2bb8dffd31 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 9 Feb 2018 23:07:42 +0100 Subject: core/imagedownloader.cpp: Use signal to exit eventloop Don't do busy-waiting. Signed-off-by: Berthold Stoeger --- core/imagedownloader.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'core/imagedownloader.cpp') diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index 9a8463b7e..42ab52f0f 100644 --- a/core/imagedownloader.cpp +++ b/core/imagedownloader.cpp @@ -42,11 +42,9 @@ bool ImageDownloader::loadFromUrl(const QUrl &url) QNetworkRequest request(url); connect(&manager, &QNetworkAccessManager::finished, this, [this,&success] (QNetworkReply *reply) { saveImage(reply, success); }); + connect(&manager, &QNetworkAccessManager::finished, &loop, &QEventLoop::quit); QNetworkReply *reply = manager.get(request); - while (reply->isRunning()) { - loop.processEvents(); - sleep(1); - } + loop.exec(); delete reply; } return success; -- cgit v1.2.3-70-g09d2