From e660cccec5b64f9167518b9d50b4fef31fc96461 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 19 Apr 2019 13:16:41 -0700 Subject: [PATCH 1/2] Prevent double reporting of tile download errors --- src/QtLocationPlugin/QGCMapTileSet.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/QtLocationPlugin/QGCMapTileSet.cpp b/src/QtLocationPlugin/QGCMapTileSet.cpp index f2ac50f..11d5ef7 100644 --- a/src/QtLocationPlugin/QGCMapTileSet.cpp +++ b/src/QtLocationPlugin/QGCMapTileSet.cpp @@ -268,6 +268,10 @@ QGCCachedTileSet::_networkReplyFinished() qWarning() << "QGCMapEngineManager::networkReplyFinished() NULL Reply"; return; } + if (reply->error() != QNetworkReply::NoError) { + // Error was already handled in _networkReplyError implementation + return; + } //-- Get tile hash const QString hash = reply->request().attribute(QNetworkRequest::User).toString(); if(!hash.isEmpty()) { @@ -276,10 +280,6 @@ QGCCachedTileSet::_networkReplyFinished() } else { qWarning() << "QGCMapEngineManager::networkReplyFinished() Reply not in list: " << hash; } - if (reply->error() != QNetworkReply::NoError) { - qWarning() << "QGCMapEngineManager::networkReplyFinished() Error:" << reply->errorString(); - return; - } qCDebug(QGCCachedTileSetLog) << "Tile fetched" << hash; QByteArray image = reply->readAll(); UrlFactory::MapType type = getQGCMapEngine()->hashToType(hash); From ae4d5f6e39d9c6f3edb47d6e096b0a0bbe3330be Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Fri, 19 Apr 2019 13:44:17 -0700 Subject: [PATCH 2/2] Fix double tile download error reporting --- src/QtLocationPlugin/QGCMapTileSet.cpp | 78 +++++++++++++++++----------------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/src/QtLocationPlugin/QGCMapTileSet.cpp b/src/QtLocationPlugin/QGCMapTileSet.cpp index 11d5ef7..d9d0145 100644 --- a/src/QtLocationPlugin/QGCMapTileSet.cpp +++ b/src/QtLocationPlugin/QGCMapTileSet.cpp @@ -268,48 +268,46 @@ QGCCachedTileSet::_networkReplyFinished() qWarning() << "QGCMapEngineManager::networkReplyFinished() NULL Reply"; return; } - if (reply->error() != QNetworkReply::NoError) { - // Error was already handled in _networkReplyError implementation - return; - } - //-- Get tile hash - const QString hash = reply->request().attribute(QNetworkRequest::User).toString(); - if(!hash.isEmpty()) { - if(_replies.contains(hash)) { - _replies.remove(hash); - } else { - qWarning() << "QGCMapEngineManager::networkReplyFinished() Reply not in list: " << hash; - } - qCDebug(QGCCachedTileSetLog) << "Tile fetched" << hash; - QByteArray image = reply->readAll(); - UrlFactory::MapType type = getQGCMapEngine()->hashToType(hash); - if (type == UrlFactory::MapType::AirmapElevation) { - image = TerrainTile::serialize(image); - } - QString format = getQGCMapEngine()->urlFactory()->getImageFormat(type, image); - if(!format.isEmpty()) { - //-- Cache tile - getQGCMapEngine()->cacheTile(type, hash, image, format, _id); - QGCUpdateTileDownloadStateTask* task = new QGCUpdateTileDownloadStateTask(_id, QGCTile::StateComplete, hash); - getQGCMapEngine()->addTask(task); - //-- Updated cached (downloaded) data - _savedTileSize += image.size(); - _savedTileCount++; - emit savedTileSizeChanged(); - emit savedTileCountChanged(); - //-- Update estimate - if(_savedTileCount % 10 == 0) { - quint32 avg = _savedTileSize / _savedTileCount; - _totalTileSize = avg * _totalTileCount; - _uniqueTileSize = avg * _uniqueTileCount; - emit totalTilesSizeChanged(); - emit uniqueTileSizeChanged(); + if (reply->error() == QNetworkReply::NoError) { + //-- Get tile hash + const QString hash = reply->request().attribute(QNetworkRequest::User).toString(); + if(!hash.isEmpty()) { + if(_replies.contains(hash)) { + _replies.remove(hash); + } else { + qWarning() << "QGCMapEngineManager::networkReplyFinished() Reply not in list: " << hash; + } + qCDebug(QGCCachedTileSetLog) << "Tile fetched" << hash; + QByteArray image = reply->readAll(); + UrlFactory::MapType type = getQGCMapEngine()->hashToType(hash); + if (type == UrlFactory::MapType::AirmapElevation) { + image = TerrainTile::serialize(image); } + QString format = getQGCMapEngine()->urlFactory()->getImageFormat(type, image); + if(!format.isEmpty()) { + //-- Cache tile + getQGCMapEngine()->cacheTile(type, hash, image, format, _id); + QGCUpdateTileDownloadStateTask* task = new QGCUpdateTileDownloadStateTask(_id, QGCTile::StateComplete, hash); + getQGCMapEngine()->addTask(task); + //-- Updated cached (downloaded) data + _savedTileSize += image.size(); + _savedTileCount++; + emit savedTileSizeChanged(); + emit savedTileCountChanged(); + //-- Update estimate + if(_savedTileCount % 10 == 0) { + quint32 avg = _savedTileSize / _savedTileCount; + _totalTileSize = avg * _totalTileCount; + _uniqueTileSize = avg * _uniqueTileCount; + emit totalTilesSizeChanged(); + emit uniqueTileSizeChanged(); + } + } + //-- Setup a new download + _prepareDownload(); + } else { + qWarning() << "QGCMapEngineManager::networkReplyFinished() Empty Hash"; } - //-- Setup a new download - _prepareDownload(); - } else { - qWarning() << "QGCMapEngineManager::networkReplyFinished() Empty Hash"; } reply->deleteLater(); }