diff options
author | Paolo Angelelli <paolo.angelelli@theqtcompany.com> | 2016-07-01 15:00:03 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@theqtcompany.com> | 2016-07-07 13:09:43 +0000 |
commit | fd7ad01376b511ef1065ff832a7e41f15f6175b3 (patch) | |
tree | c04e0c7a03a3fb73cc875638faa0657d8d3c9cc7 | |
parent | eaf416e17fecee09c0b3f8d93b784fc3cf5806d2 (diff) | |
download | qtlocation-fd7ad01376b511ef1065ff832a7e41f15f6175b3.tar.gz |
Fix for caching after mapbox improvement/highdpi-support
Currently the qgeofiletilecache/qgeofiletilecachemapbox contains a bug
in that it makes use of virtual functions in the constructor.
This patch fixes it by moving those calls into a virtual init()
method that is called by QGeoTiledMappingManagerEngine::setTileCache()
Change-Id: Icf7932dfbae7d99eef22c67e034246a834212a03
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
6 files changed, 13 insertions, 5 deletions
diff --git a/src/location/maps/qabstractgeotilecache_p.h b/src/location/maps/qabstractgeotilecache_p.h index 141aa9b4..bf1e56b9 100644 --- a/src/location/maps/qabstractgeotilecache_p.h +++ b/src/location/maps/qabstractgeotilecache_p.h @@ -116,8 +116,10 @@ public: protected: QAbstractGeoTileCache(QObject *parent = 0); - + virtual void init() = 0; virtual void printStats() = 0; + + friend class QGeoTiledMappingManagerEngine; }; QT_END_NAMESPACE diff --git a/src/location/maps/qgeofiletilecache.cpp b/src/location/maps/qgeofiletilecache.cpp index 73c9fe29..520649ea 100644 --- a/src/location/maps/qgeofiletilecache.cpp +++ b/src/location/maps/qgeofiletilecache.cpp @@ -86,8 +86,12 @@ QGeoCachedTileDisk::~QGeoCachedTileDisk() } QGeoFileTileCache::QGeoFileTileCache(const QString &directory, QObject *parent) - : QAbstractGeoTileCache(parent), directory_(directory), - minTextureUsage_(0), extraTextureUsage_(0) + : QAbstractGeoTileCache(parent), directory_(directory), minTextureUsage_(0), extraTextureUsage_(0) +{ + +} + +void QGeoFileTileCache::init() { const QString basePath = baseCacheDirectory(); diff --git a/src/location/maps/qgeofiletilecache_p.h b/src/location/maps/qgeofiletilecache_p.h index caaa0b07..920ee56c 100644 --- a/src/location/maps/qgeofiletilecache_p.h +++ b/src/location/maps/qgeofiletilecache_p.h @@ -129,6 +129,7 @@ public: QGeoTiledMappingManagerEngine::CacheAreas areas = QGeoTiledMappingManagerEngine::AllCaches) Q_DECL_OVERRIDE; protected: + void init() Q_DECL_OVERRIDE; void printStats() Q_DECL_OVERRIDE; void loadTiles(); diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp index 4e777ab2..83b1c006 100644 --- a/src/location/maps/qgeotiledmappingmanagerengine.cpp +++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp @@ -280,6 +280,7 @@ void QGeoTiledMappingManagerEngine::setTileCache(QAbstractGeoTileCache *cache) Q_D(QGeoTiledMappingManagerEngine); Q_ASSERT_X(!d->tileCache_, Q_FUNC_INFO, "This should be called only once"); d->tileCache_ = cache; + d->tileCache_->init(); } QAbstractGeoTileCache *QGeoTiledMappingManagerEngine::tileCache() @@ -290,6 +291,7 @@ QAbstractGeoTileCache *QGeoTiledMappingManagerEngine::tileCache() if (!managerName().isEmpty()) cacheDirectory = QAbstractGeoTileCache::baseCacheDirectory() + managerName(); d->tileCache_ = new QGeoFileTileCache(cacheDirectory); + d->tileCache_->init(); } return d->tileCache_; } diff --git a/src/plugins/geoservices/mapbox/qgeofiletilecachemapbox.h b/src/plugins/geoservices/mapbox/qgeofiletilecachemapbox.h index 189efc10..e96e5ab0 100644 --- a/src/plugins/geoservices/mapbox/qgeofiletilecachemapbox.h +++ b/src/plugins/geoservices/mapbox/qgeofiletilecachemapbox.h @@ -39,7 +39,6 @@ #include <QtLocation/private/qgeofiletilecache_p.h> #include <QMap> -#include <QLatin1String> QT_BEGIN_NAMESPACE diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp index 64449d1d..5acbfed5 100644 --- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp @@ -115,7 +115,7 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia( m_cacheDirectory = QAbstractGeoTileCache::baseCacheDirectory() + QLatin1String("here"); } - QAbstractGeoTileCache *tileCache = new QGeoFileTileCache(m_cacheDirectory); + QGeoFileTileCache *tileCache = new QGeoFileTileCache(m_cacheDirectory); setTileCache(tileCache); if (parameters.contains(QStringLiteral("here.mapping.cache.disk.size"))) { |