Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix QgsFileDownloader thinks ANY timeout or ssl error applies to its …
…request
  • Loading branch information
nyalldawson committed Jan 23, 2019
1 parent ea1971f commit 1190000
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions src/core/qgsfiledownloader.cpp
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsfiledownloader.h
Expand Up @@ -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

Expand Down

0 comments on commit 1190000

Please sign in to comment.