summaryrefslogtreecommitdiff
path: root/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@jollamobile.com>2014-02-10 13:16:15 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-10 14:48:25 +0100
commitcdf5af5ba4c80c98cf4967ecf82ecac80ce3b854 (patch)
tree6e5701ac6f5b2c602353430962f6ea5621d46fbc /src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
parent62234914bc39be509c6a764c99d592e0bc5ecb5c (diff)
downloadqtlocation-cdf5af5ba4c80c98cf4967ecf82ecac80ce3b854.tar.gz
Test that the mapping manager engine pointer is still valid.
QPointer holds a guarded pointer to a QObject. It must always be tested prior to use. Changed the parameter type to remove the need for the static_cast when setting the QPointer member. The root cause was that the tile fetcher object was not being destroyed when the mapping manager engine was. Which was because the two objects were in different threads. Some of the service specific tile fetchers were directly calling into the engine objects across thread. Gah. Since Qt 5 QNAM uses an application global thread for processing requests, there is no need to use threads in the tile fetcher. Change-Id: Id9df35ddfa78df2cbf334006fe5fc9726a75f92d Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp')
-rw-r--r--src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp45
1 files changed, 19 insertions, 26 deletions
diff --git a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
index 997eef64..ddd55ec4 100644
--- a/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
+++ b/src/plugins/geoservices/nokia/qgeotilefetcher_nokia.cpp
@@ -86,44 +86,34 @@ namespace
return mapScheme.startsWith("satellite") || mapScheme.startsWith("hybrid") || mapScheme.startsWith("terrain");
}
}
-QGeoTileFetcherNokia::QGeoTileFetcherNokia(
- const QVariantMap &parameters,
- QGeoNetworkAccessManager *networkManager,
- QGeoTiledMappingManagerEngine *engine,
- const QSize &tileSize)
- : QGeoTileFetcher(engine),
- m_engineNokia(static_cast<QGeoTiledMappingManagerEngineNokia *>(engine)),
- m_networkManager(networkManager),
- m_parameters(parameters),
- m_tileSize(tileSize),
- m_copyrightsReply(0),
- m_baseUriProvider(new QGeoUriProvider(this, parameters, "mapping.host", MAP_TILES_HOST)),
- m_aerialUriProvider(new QGeoUriProvider(this, parameters, "mapping.host.aerial", MAP_TILES_HOST_AERIAL))
+QGeoTileFetcherNokia::QGeoTileFetcherNokia(const QVariantMap &parameters,
+ QGeoNetworkAccessManager *networkManager,
+ QGeoTiledMappingManagerEngineNokia *engine,
+ const QSize &tileSize)
+: QGeoTileFetcher(engine), m_engineNokia(engine), m_networkManager(networkManager),
+ m_tileSize(tileSize), m_copyrightsReply(0),
+ m_baseUriProvider(new QGeoUriProvider(this, parameters, "mapping.host", MAP_TILES_HOST)),
+ m_aerialUriProvider(new QGeoUriProvider(this, parameters, "mapping.host.aerial", MAP_TILES_HOST_AERIAL))
{
Q_ASSERT(networkManager);
m_networkManager->setParent(this);
-}
-QGeoTileFetcherNokia::~QGeoTileFetcherNokia() {}
+ m_applicationId = parameters.value(QStringLiteral("app_id")).toString();
+ m_token = parameters.value(QStringLiteral("token")).toString();
+}
-bool QGeoTileFetcherNokia::init()
+QGeoTileFetcherNokia::~QGeoTileFetcherNokia()
{
- qsrand((uint)QTime::currentTime().msec());
-
- if (m_parameters.contains("app_id")) {
- m_applicationId = m_parameters.value("app_id").toString();
- }
-
- if (m_parameters.contains("token")) {
- m_token = m_parameters.value("token").toString();
- }
- return true;
}
QGeoTiledMapReply *QGeoTileFetcherNokia::getTileImage(const QGeoTileSpec &spec)
{
// TODO add error detection for if request.connectivityMode() != QGraphicsGeoMap::OnlineMode
QString rawRequest = getRequestString(spec);
+ if (rawRequest.isEmpty()) {
+ return new QGeoTiledMapReply(QGeoTiledMapReply::UnknownError,
+ tr("Mapping manager no longer exists"), this);
+ }
QNetworkRequest netRequest((QUrl(rawRequest))); // The extra pair of parens disambiguates this from a function declaration
netRequest.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true);
@@ -137,6 +127,9 @@ QGeoTiledMapReply *QGeoTileFetcherNokia::getTileImage(const QGeoTileSpec &spec)
QString QGeoTileFetcherNokia::getRequestString(const QGeoTileSpec &spec)
{
+ if (!m_engineNokia)
+ return QString();
+
static const QString http("http://");
static const QString path("/maptile/2.1/maptile/newest/");
static const QChar slash('/');