mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 03:35:53 +01:00
Fixed infinite download loop on broken tile images
Added support for HTTP redirects
This commit is contained in:
parent
40803d68c1
commit
31f6eeac26
@ -64,8 +64,15 @@ void Downloader::downloadFinished(QNetworkReply *reply)
|
||||
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||
} else {
|
||||
QUrl redirect = reply->attribute(
|
||||
QNetworkRequest::RedirectionTargetAttribute).toUrl();
|
||||
QString filename = reply->request().attribute(QNetworkRequest::User)
|
||||
.toString();
|
||||
|
||||
if (!redirect.isEmpty()) {
|
||||
Download dl(redirect, filename);
|
||||
doDownload(dl);
|
||||
} else
|
||||
saveToDisk(filename, reply);
|
||||
}
|
||||
|
||||
|
@ -12,13 +12,13 @@
|
||||
class Download
|
||||
{
|
||||
public:
|
||||
Download(const QString &url, const QString &file)
|
||||
Download(const QUrl &url, const QString &file)
|
||||
{_url = url; _file = file;}
|
||||
const QString& url() const {return _url;}
|
||||
const QUrl& url() const {return _url;}
|
||||
const QString& file() const {return _file;}
|
||||
|
||||
private:
|
||||
QString _url;
|
||||
QUrl _url;
|
||||
QString _file;
|
||||
};
|
||||
|
||||
|
@ -42,10 +42,11 @@ void Map::loadTilesAsync(QList<Tile> &list)
|
||||
QString file = tileFile(t);
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (!(fi.exists() && loadTileFile(t, file))) {
|
||||
if (!fi.exists()) {
|
||||
fillTile(t);
|
||||
dl.append(Download(tileUrl(t), file));
|
||||
}
|
||||
} else
|
||||
loadTileFile(t, file);
|
||||
}
|
||||
|
||||
if (!dl.empty())
|
||||
@ -61,8 +62,10 @@ void Map::loadTilesSync(QList<Tile> &list)
|
||||
QString file = tileFile(t);
|
||||
QFileInfo fi(file);
|
||||
|
||||
if (!(fi.exists() && loadTileFile(t, file)))
|
||||
if (!fi.exists())
|
||||
dl.append(Download(tileUrl(t), file));
|
||||
else
|
||||
loadTileFile(t, file);
|
||||
}
|
||||
|
||||
if (dl.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user