summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeofiletilecache.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/location/maps/qgeofiletilecache.cpp')
-rw-r--r--src/location/maps/qgeofiletilecache.cpp31
1 files changed, 26 insertions, 5 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();