Skip to content
Permalink
Browse files

Fix QgsFileDownloader thinks ANY timeout or ssl error applies to its …

…request
  • Loading branch information
nyalldawson committed Jan 23, 2019
1 parent ea1971f commit 1190000aaf7f3de93cd45607271e706a7923fc88
Showing with 14 additions and 10 deletions.
  1. +13 −9 src/core/qgsfiledownloader.cpp
  2. +1 −1 src/core/qgsfiledownloader.h
@@ -74,7 +74,7 @@ void QgsFileDownloader::startDownload()
connect( mReply, &QNetworkReply::readyRead, this, &QgsFileDownloader::onReadyRead );
connect( mReply, &QNetworkReply::finished, this, &QgsFileDownloader::onFinished );
connect( mReply, &QNetworkReply::downloadProgress, this, &QgsFileDownloader::onDownloadProgress );
connect( nam, &QgsNetworkAccessManager::requestTimedOut, this, &QgsFileDownloader::onRequestTimedOut, Qt::UniqueConnection );
connect( nam, qgis::overload< QNetworkReply *>::of( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsFileDownloader::onRequestTimedOut, Qt::UniqueConnection );
#ifndef QT_NO_SSL
connect( nam, &QgsNetworkAccessManager::sslErrors, this, &QgsFileDownloader::onSslErrors, Qt::UniqueConnection );
#endif
@@ -87,22 +87,26 @@ void QgsFileDownloader::cancelDownload()
onFinished();
}

void QgsFileDownloader::onRequestTimedOut()
void QgsFileDownloader::onRequestTimedOut( QNetworkReply *reply )
{
error( tr( "Network request %1 timed out" ).arg( mUrl.toString() ) );
if ( reply == mReply )
error( tr( "Network request %1 timed out" ).arg( mUrl.toString() ) );
}

#ifndef QT_NO_SSL
void QgsFileDownloader::onSslErrors( QNetworkReply *reply, const QList<QSslError> &errors )
{
Q_UNUSED( reply );
QStringList errorMessages;
errorMessages << QStringLiteral( "SSL Errors: " );
for ( auto end = errors.size(), i = 0; i != end; ++i )
if ( reply == mReply )
{
errorMessages << errors[i].errorString();
QStringList errorMessages;
errorMessages.reserve( errors.size() + 1 );
errorMessages << QStringLiteral( "SSL Errors: " );
for ( auto end = errors.size(), i = 0; i != end; ++i )
{
errorMessages << errors[i].errorString();
}
error( errorMessages );
}
error( errorMessages );
}
#endif

@@ -94,7 +94,7 @@ class CORE_EXPORT QgsFileDownloader : public QObject
//! Called on data ready to be processed
void onDownloadProgress( qint64 bytesReceived, qint64 bytesTotal );
//! Called when a network request times out
void onRequestTimedOut();
void onRequestTimedOut( QNetworkReply *reply );

#ifndef QT_NO_SSL

0 comments on commit 1190000

Please sign in to comment.
You can’t perform that action at this time.