mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-27 21:24:47 +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",
|
fprintf(stderr, "Error downloading map tile: %s: %s\n",
|
||||||
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
url.toEncoded().constData(), qPrintable(reply->errorString()));
|
||||||
} else {
|
} else {
|
||||||
|
QUrl redirect = reply->attribute(
|
||||||
|
QNetworkRequest::RedirectionTargetAttribute).toUrl();
|
||||||
QString filename = reply->request().attribute(QNetworkRequest::User)
|
QString filename = reply->request().attribute(QNetworkRequest::User)
|
||||||
.toString();
|
.toString();
|
||||||
|
|
||||||
|
if (!redirect.isEmpty()) {
|
||||||
|
Download dl(redirect, filename);
|
||||||
|
doDownload(dl);
|
||||||
|
} else
|
||||||
saveToDisk(filename, reply);
|
saveToDisk(filename, reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,13 @@
|
|||||||
class Download
|
class Download
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Download(const QString &url, const QString &file)
|
Download(const QUrl &url, const QString &file)
|
||||||
{_url = url; _file = file;}
|
{_url = url; _file = file;}
|
||||||
const QString& url() const {return _url;}
|
const QUrl& url() const {return _url;}
|
||||||
const QString& file() const {return _file;}
|
const QString& file() const {return _file;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _url;
|
QUrl _url;
|
||||||
QString _file;
|
QString _file;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -42,10 +42,11 @@ void Map::loadTilesAsync(QList<Tile> &list)
|
|||||||
QString file = tileFile(t);
|
QString file = tileFile(t);
|
||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
|
|
||||||
if (!(fi.exists() && loadTileFile(t, file))) {
|
if (!fi.exists()) {
|
||||||
fillTile(t);
|
fillTile(t);
|
||||||
dl.append(Download(tileUrl(t), file));
|
dl.append(Download(tileUrl(t), file));
|
||||||
}
|
} else
|
||||||
|
loadTileFile(t, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dl.empty())
|
if (!dl.empty())
|
||||||
@ -61,8 +62,10 @@ void Map::loadTilesSync(QList<Tile> &list)
|
|||||||
QString file = tileFile(t);
|
QString file = tileFile(t);
|
||||||
QFileInfo fi(file);
|
QFileInfo fi(file);
|
||||||
|
|
||||||
if (!(fi.exists() && loadTileFile(t, file)))
|
if (!fi.exists())
|
||||||
dl.append(Download(tileUrl(t), file));
|
dl.append(Download(tileUrl(t), file));
|
||||||
|
else
|
||||||
|
loadTileFile(t, file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dl.empty())
|
if (dl.empty())
|
||||||
|
Loading…
Reference in New Issue
Block a user