summaryrefslogtreecommitdiffstats
path: root/core/divesitehelpers.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-11 18:44:05 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-11 16:25:02 -0700
commitce8199cdfdef97437ad85178c7104f307baf018b (patch)
tree4979946f2e5128e8508b9359dbdc62dce0bc1864 /core/divesitehelpers.cpp
parent76e5c5ac671fdeb29cf667d478a27757054d67cb (diff)
downloadsubsurface-ce8199cdfdef97437ad85178c7104f307baf018b.tar.gz
Cleanup: remove ReverseGeoLookupThread
Fetching the taxonomy from GPS coordinates was implemented in a QThread. But the only access to the main function was a direct call to run(). Thus, the thread was *never* started. The function call was always asynchronous [it was using an event loop though, so the UI doesn't hang]. Notably this means that the signals connected to the thread would never fire. And the spinner would never be activated. Thus: 1) Turn the thread into a simple function. 2) Remove the spinner. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/divesitehelpers.cpp')
-rw-r--r--core/divesitehelpers.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/core/divesitehelpers.cpp b/core/divesitehelpers.cpp
index 3f752a320..b77bc8fec 100644
--- a/core/divesitehelpers.cpp
+++ b/core/divesitehelpers.cpp
@@ -20,17 +20,7 @@
#include <QEventLoop>
#include <QTimer>
-ReverseGeoLookupThread* ReverseGeoLookupThread::instance()
-{
- static ReverseGeoLookupThread* self = new ReverseGeoLookupThread();
- return self;
-}
-
-ReverseGeoLookupThread::ReverseGeoLookupThread(QObject *obj) : QThread(obj)
-{
-}
-
-void ReverseGeoLookupThread::run()
+void reverseGeoLookup()
{
QNetworkRequest request;
QNetworkAccessManager *rgl = new QNetworkAccessManager();
@@ -41,7 +31,7 @@ void ReverseGeoLookupThread::run()
request.setRawHeader("Accept", "text/json");
request.setRawHeader("User-Agent", getUserAgent().toUtf8());
- connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+ QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
struct dive_site *ds = &displayed_dive_site;
@@ -50,7 +40,7 @@ void ReverseGeoLookupThread::run()
QNetworkReply *reply = rgl->get(request);
timer.setSingleShot(true);
- connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
+ QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
timer.start(5000); // 5 secs. timeout
loop.exec();
@@ -119,13 +109,13 @@ void ReverseGeoLookupThread::run()
}
} else {
report_error("timeout accessing geonames.org");
- disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
+ QObject::disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
reply->abort();
}
// next check the oceans API to figure out the body of water
request.setUrl(geonamesOceanURL.arg(uiLanguage(NULL).section(QRegExp("[-_ ]"), 0, 0)).arg(ds->latitude.udeg / 1000000.0).arg(ds->longitude.udeg / 1000000.0));
reply = rgl->get(request);
- connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
+ QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
timer.start(5000); // 5 secs. timeout
loop.exec();
if (timer.isActive()) {
@@ -165,7 +155,7 @@ void ReverseGeoLookupThread::run()
}
} else {
report_error("timeout accessing geonames.org");
- disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
+ QObject::disconnect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
reply->abort();
}