summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-02-09 23:07:42 +0100
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-03-05 18:04:57 +0200
commiteaff0ddee73d8fa0569d06a79716bf2bb8dffd31 (patch)
tree195a5fb3ea80e1d2ef69dc78859ffce8b3f02fe7
parent907c07ce50a3fdaab8e1c6470271e828a55290d6 (diff)
downloadsubsurface-eaff0ddee73d8fa0569d06a79716bf2bb8dffd31.tar.gz
core/imagedownloader.cpp: Use signal to exit eventloop
Don't do busy-waiting. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--core/imagedownloader.cpp6
1 files changed, 2 insertions, 4 deletions
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;