summaryrefslogtreecommitdiff
path: root/src/location/maps
diff options
context:
space:
mode:
Diffstat (limited to 'src/location/maps')
-rw-r--r--src/location/maps/qgeofiletilecache.cpp31
-rw-r--r--src/location/maps/qgeofiletilecache_p.h3
-rw-r--r--src/location/maps/qgeomaptype.cpp20
-rw-r--r--src/location/maps/qgeomaptype_p.h3
-rw-r--r--src/location/maps/qgeomaptype_p_p.h5
-rw-r--r--src/location/maps/qgeotiledmap.cpp2
-rw-r--r--src/location/maps/qgeotilerequestmanager.cpp5
7 files changed, 51 insertions, 18 deletions
diff --git a/src/location/maps/qgeofiletilecache.cpp b/src/location/maps/qgeofiletilecache.cpp
index a583e66a..ede900bd 100644
--- a/src/location/maps/qgeofiletilecache.cpp
+++ b/src/location/maps/qgeofiletilecache.cpp
@@ -151,7 +151,7 @@ void QGeoFileTileCache::loadTiles()
QDir dir(directory_);
QStringList files = dir.entryList(formats, QDir::Files);
-
+#if 0 // workaround for QTBUG-60581
// Method:
// 1. read each queue file then, if each file exists, deserialize the data into the appropriate
// cache queue.
@@ -189,7 +189,7 @@ void QGeoFileTileCache::loadTiles()
diskCache_.deserializeQueue(i, specs, queue, costs);
file.close();
}
-
+#endif
// 2. remaining tiles that aren't registered in a queue get pushed into cache here
// this is a backup, in case the queue manifest files get deleted or out of sync due to
// the application not closing down properly
@@ -204,6 +204,7 @@ void QGeoFileTileCache::loadTiles()
QGeoFileTileCache::~QGeoFileTileCache()
{
+#if 0 // workaround for QTBUG-60581
// write disk cache queues to disk
QDir dir(directory_);
for (int i = 1; i<=4; i++) {
@@ -226,6 +227,7 @@ QGeoFileTileCache::~QGeoFileTileCache()
}
file.close();
}
+#endif
}
void QGeoFileTileCache::printStats()
@@ -424,8 +426,11 @@ QSharedPointer<QGeoCachedTileDisk> QGeoFileTileCache::addToDiskCache(const QGeoT
return td;
}
-QSharedPointer<QGeoCachedTileMemory> QGeoFileTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format)
+void QGeoFileTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format)
{
+ if (isTileBogus(bytes))
+ return;
+
QSharedPointer<QGeoCachedTileMemory> tm(new QGeoCachedTileMemory);
tm->spec = spec;
tm->cache = this;
@@ -436,8 +441,6 @@ QSharedPointer<QGeoCachedTileMemory> QGeoFileTileCache::addToMemoryCache(const Q
if (costStrategyMemory_ == ByteSize)
cost = bytes.size();
memoryCache_.insert(spec, tm, cost);
-
- return tm;
}
QSharedPointer<QGeoTileTexture> QGeoFileTileCache::addToTextureCache(const QGeoTileSpec &spec, const QImage &image)
@@ -485,6 +488,17 @@ QSharedPointer<QGeoTileTexture> QGeoFileTileCache::getFromDisk(const QGeoTileSpe
file.close();
QImage image;
+ // Some tiles from the servers could be valid images but the tile fetcher
+ // might be able to recognize them as tiles that should not be shown.
+ // If that's the case, the tile fetcher should write "NoRetry" inside the file.
+ if (isTileBogus(bytes)) {
+ QSharedPointer<QGeoTileTexture> tt(new QGeoTileTexture);
+ tt->spec = spec;
+ tt->image = image;
+ return tt;
+ }
+
+ // This is a truly invalid image. The fetcher should try again.
if (!image.loadFromData(bytes)) {
handleError(spec, QLatin1String("Problem with tile image"));
return QSharedPointer<QGeoTileTexture>(0);
@@ -503,6 +517,13 @@ QSharedPointer<QGeoTileTexture> QGeoFileTileCache::getFromDisk(const QGeoTileSpe
return QSharedPointer<QGeoTileTexture>();
}
+bool QGeoFileTileCache::isTileBogus(const QByteArray &bytes) const
+{
+ if (bytes.size() == 7 && bytes == QByteArrayLiteral("NoRetry"))
+ return true;
+ return false;
+}
+
QString QGeoFileTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) const
{
QString filename = spec.plugin();
diff --git a/src/location/maps/qgeofiletilecache_p.h b/src/location/maps/qgeofiletilecache_p.h
index 2da7c95f..2ae40d36 100644
--- a/src/location/maps/qgeofiletilecache_p.h
+++ b/src/location/maps/qgeofiletilecache_p.h
@@ -144,11 +144,12 @@ protected:
QString directory() const;
QSharedPointer<QGeoCachedTileDisk> addToDiskCache(const QGeoTileSpec &spec, const QString &filename);
- QSharedPointer<QGeoCachedTileMemory> addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format);
+ void addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format);
QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QImage &image);
QSharedPointer<QGeoTileTexture> getFromMemory(const QGeoTileSpec &spec);
QSharedPointer<QGeoTileTexture> getFromDisk(const QGeoTileSpec &spec);
+ virtual bool isTileBogus(const QByteArray &bytes) const;
virtual QString tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) const;
virtual QGeoTileSpec filenameToTileSpec(const QString &filename) const;
diff --git a/src/location/maps/qgeomaptype.cpp b/src/location/maps/qgeomaptype.cpp
index b4efa1d9..34781451 100644
--- a/src/location/maps/qgeomaptype.cpp
+++ b/src/location/maps/qgeomaptype.cpp
@@ -46,8 +46,8 @@ QGeoMapType::QGeoMapType(const QGeoMapType &other)
: d_ptr(other.d_ptr) {}
QGeoMapType::QGeoMapType(QGeoMapType::MapStyle style, const QString &name,
- const QString &description, bool mobile, bool night, int mapId)
-: d_ptr(new QGeoMapTypePrivate(style, name, description, mobile, night, mapId))
+ const QString &description, bool mobile, bool night, int mapId, QByteArray pluginName)
+: d_ptr(new QGeoMapTypePrivate(style, name, description, mobile, night, mapId, pluginName))
{
}
@@ -102,6 +102,11 @@ int QGeoMapType::mapId() const
return d_ptr->mapId_;
}
+QByteArray QGeoMapType::pluginName() const
+{
+ return d_ptr->pluginName_;
+}
+
QGeoMapTypePrivate::QGeoMapTypePrivate()
: style_(QGeoMapType::NoMap), mobile_(false), night_(false), mapId_(0)
{
@@ -109,15 +114,15 @@ QGeoMapTypePrivate::QGeoMapTypePrivate()
QGeoMapTypePrivate::QGeoMapTypePrivate(const QGeoMapTypePrivate &other)
: QSharedData(other), style_(other.style_), name_(other.name_), description_(other.description_),
- mobile_(other.mobile_), night_(other.night_), mapId_(other.mapId_)
+ mobile_(other.mobile_), night_(other.night_), mapId_(other.mapId_), pluginName_(other.pluginName_)
{
}
QGeoMapTypePrivate::QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name,
const QString &description, bool mobile, bool night,
- int mapId)
+ int mapId, QByteArray pluginName)
: style_(style), name_(name), description_(description), mobile_(mobile), night_(night),
- mapId_(mapId)
+ mapId_(mapId), pluginName_(pluginName)
{
}
@@ -127,8 +132,9 @@ QGeoMapTypePrivate::~QGeoMapTypePrivate()
bool QGeoMapTypePrivate::operator==(const QGeoMapTypePrivate &other) const
{
- return style_ == other.style_ && name_ == other.name_ && description_ == other.description_ &&
- mobile_ == other.mobile_ && night_ == other.night_ && mapId_ == other.mapId_;
+ return pluginName_ == other.pluginName_ && style_ == other.style_ && name_ == other.name_ &&
+ description_ == other.description_ && mobile_ == other.mobile_ && night_ == other.night_ &&
+ mapId_ == other.mapId_;
}
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeomaptype_p.h b/src/location/maps/qgeomaptype_p.h
index f26471f4..4b5cb0d0 100644
--- a/src/location/maps/qgeomaptype_p.h
+++ b/src/location/maps/qgeomaptype_p.h
@@ -77,7 +77,7 @@ public:
QGeoMapType();
QGeoMapType(const QGeoMapType &other);
QGeoMapType(MapStyle style, const QString &name, const QString &description, bool mobile,
- bool night, int mapId);
+ bool night, int mapId, QByteArray pluginName);
~QGeoMapType();
QGeoMapType &operator = (const QGeoMapType &other);
@@ -91,6 +91,7 @@ public:
bool mobile() const;
bool night() const;
int mapId() const;
+ QByteArray pluginName() const;
private:
QSharedDataPointer<QGeoMapTypePrivate> d_ptr;
diff --git a/src/location/maps/qgeomaptype_p_p.h b/src/location/maps/qgeomaptype_p_p.h
index 2aafd37b..039c0962 100644
--- a/src/location/maps/qgeomaptype_p_p.h
+++ b/src/location/maps/qgeomaptype_p_p.h
@@ -50,6 +50,7 @@
#include <QMetaType>
#include <QString>
+#include <QByteArray>
#include <QSharedData>
#include "qgeomaptype_p.h"
@@ -60,7 +61,8 @@ class QGeoMapTypePrivate : public QSharedData
{
public:
QGeoMapTypePrivate();
- QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name, const QString &description, bool mobile, bool night, int mapId);
+ QGeoMapTypePrivate(QGeoMapType::MapStyle style, const QString &name, const QString &description, bool mobile,
+ bool night, int mapId, QByteArray pluginName);
QGeoMapTypePrivate(const QGeoMapTypePrivate &other);
~QGeoMapTypePrivate();
@@ -74,6 +76,7 @@ public:
bool mobile_;
bool night_;
int mapId_;
+ QByteArray pluginName_;
};
QT_END_NAMESPACE
diff --git a/src/location/maps/qgeotiledmap.cpp b/src/location/maps/qgeotiledmap.cpp
index dbfe45ea..0eeb189d 100644
--- a/src/location/maps/qgeotiledmap.cpp
+++ b/src/location/maps/qgeotiledmap.cpp
@@ -391,7 +391,7 @@ void QGeoTiledMapPrivate::updateTile(const QGeoTileSpec &spec)
// Only promote the texture up to GPU if it is visible
if (m_visibleTiles->createTiles().contains(spec)){
QSharedPointer<QGeoTileTexture> tex = m_tileRequests->tileTexture(spec);
- if (!tex.isNull()) {
+ if (!tex.isNull() && !tex->image.isNull()) {
m_mapScene->addTile(spec, tex);
emit q->sgNodeChanged();
}
diff --git a/src/location/maps/qgeotilerequestmanager.cpp b/src/location/maps/qgeotilerequestmanager.cpp
index 7672a98f..d4d94ad0 100644
--- a/src/location/maps/qgeotilerequestmanager.cpp
+++ b/src/location/maps/qgeotilerequestmanager.cpp
@@ -127,7 +127,8 @@ QMap<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPriva
QGeoTileSpec tile = *i;
QSharedPointer<QGeoTileTexture> tex = m_engine->getTileTexture(tile);
if (tex) {
- cachedTex.insert(tile, tex);
+ if (!tex->image.isNull())
+ cachedTex.insert(tile, tex);
cached.insert(tile);
} else {
// Try to use textures from lower zoom levels, but still request the proper tile
@@ -139,7 +140,7 @@ QMap<QGeoTileSpec, QSharedPointer<QGeoTileTexture> > QGeoTileRequestManagerPriva
spec.setX(tile.x() / denominator);
spec.setY(tile.y() / denominator);
QSharedPointer<QGeoTileTexture> t = m_engine->getTileTexture(spec);
- if (t) {
+ if (t && !t->image.isNull()) {
cachedTex.insert(tile, t);
break;
}