mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-25 10:48:04 +02:00
Never change a winning team!
This commit is contained in:
@ -79,18 +79,12 @@ private:
|
||||
int _level;
|
||||
};
|
||||
|
||||
|
||||
QNetworkAccessManager *Downloader::_manager = 0;
|
||||
int Downloader::_timeout = 30;
|
||||
#ifdef ENABLE_HTTP2
|
||||
bool Downloader::_http2 = true;
|
||||
#endif // ENABLE_HTTP2
|
||||
|
||||
QNetworkAccessManager *Downloader::manager()
|
||||
{
|
||||
static QNetworkAccessManager manager;
|
||||
return &manager;
|
||||
}
|
||||
|
||||
bool Downloader::doDownload(const Download &dl,
|
||||
const QByteArray &authorization, const Redirect *redirect)
|
||||
{
|
||||
@ -123,7 +117,8 @@ bool Downloader::doDownload(const Download &dl,
|
||||
QVariant(_http2));
|
||||
#endif // ENABLE_HTTP2
|
||||
|
||||
QNetworkReply *reply = manager()->get(request);
|
||||
Q_ASSERT(_manager);
|
||||
QNetworkReply *reply = _manager->get(request);
|
||||
if (reply && reply->isRunning()) {
|
||||
_currentDownloads.insert(url);
|
||||
ReplyTimeout::setTimeout(reply, _timeout);
|
||||
@ -236,7 +231,8 @@ bool Downloader::get(const QList<Download> &list,
|
||||
#ifdef ENABLE_HTTP2
|
||||
void Downloader::enableHTTP2(bool enable)
|
||||
{
|
||||
Q_ASSERT(_manager);
|
||||
_http2 = enable;
|
||||
manager()->clearConnectionCache();
|
||||
_manager->clearConnectionCache();
|
||||
}
|
||||
#endif // ENABLE_HTTP2
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
= Authorization());
|
||||
void clearErrors() {_errorDownloads.clear();}
|
||||
|
||||
static void setNetworkManager(QNetworkAccessManager *manager)
|
||||
{_manager = manager;}
|
||||
static void setTimeout(int timeout) {_timeout = timeout;}
|
||||
#ifdef ENABLE_HTTP2
|
||||
static void enableHTTP2(bool enable);
|
||||
@ -67,11 +69,10 @@ private:
|
||||
const Redirect *redirect = 0);
|
||||
bool saveToDisk(const QString &filename, QIODevice *data);
|
||||
|
||||
static QNetworkAccessManager *manager();
|
||||
|
||||
QSet<QUrl> _currentDownloads;
|
||||
QHash<QUrl, int> _errorDownloads;
|
||||
|
||||
static QNetworkAccessManager *_manager;
|
||||
static int _timeout;
|
||||
#ifdef ENABLE_HTTP2
|
||||
static bool _http2;
|
||||
|
Reference in New Issue
Block a user