Skip to content

Commit 1190000

Browse files
committedJan 23, 2019
Fix QgsFileDownloader thinks ANY timeout or ssl error applies to its request
1 parent ea1971f commit 1190000

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed
 

‎src/core/qgsfiledownloader.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void QgsFileDownloader::startDownload()
7474
connect( mReply, &QNetworkReply::readyRead, this, &QgsFileDownloader::onReadyRead );
7575
connect( mReply, &QNetworkReply::finished, this, &QgsFileDownloader::onFinished );
7676
connect( mReply, &QNetworkReply::downloadProgress, this, &QgsFileDownloader::onDownloadProgress );
77-
connect( nam, &QgsNetworkAccessManager::requestTimedOut, this, &QgsFileDownloader::onRequestTimedOut, Qt::UniqueConnection );
77+
connect( nam, qgis::overload< QNetworkReply *>::of( &QgsNetworkAccessManager::requestTimedOut ), this, &QgsFileDownloader::onRequestTimedOut, Qt::UniqueConnection );
7878
#ifndef QT_NO_SSL
7979
connect( nam, &QgsNetworkAccessManager::sslErrors, this, &QgsFileDownloader::onSslErrors, Qt::UniqueConnection );
8080
#endif
@@ -87,22 +87,26 @@ void QgsFileDownloader::cancelDownload()
8787
onFinished();
8888
}
8989

90-
void QgsFileDownloader::onRequestTimedOut()
90+
void QgsFileDownloader::onRequestTimedOut( QNetworkReply *reply )
9191
{
92-
error( tr( "Network request %1 timed out" ).arg( mUrl.toString() ) );
92+
if ( reply == mReply )
93+
error( tr( "Network request %1 timed out" ).arg( mUrl.toString() ) );
9394
}
9495

9596
#ifndef QT_NO_SSL
9697
void QgsFileDownloader::onSslErrors( QNetworkReply *reply, const QList<QSslError> &errors )
9798
{
98-
Q_UNUSED( reply );
99-
QStringList errorMessages;
100-
errorMessages << QStringLiteral( "SSL Errors: " );
101-
for ( auto end = errors.size(), i = 0; i != end; ++i )
99+
if ( reply == mReply )
102100
{
103-
errorMessages << errors[i].errorString();
101+
QStringList errorMessages;
102+
errorMessages.reserve( errors.size() + 1 );
103+
errorMessages << QStringLiteral( "SSL Errors: " );
104+
for ( auto end = errors.size(), i = 0; i != end; ++i )
105+
{
106+
errorMessages << errors[i].errorString();
107+
}
108+
error( errorMessages );
104109
}
105-
error( errorMessages );
106110
}
107111
#endif
108112

‎src/core/qgsfiledownloader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class CORE_EXPORT QgsFileDownloader : public QObject
9494
//! Called on data ready to be processed
9595
void onDownloadProgress( qint64 bytesReceived, qint64 bytesTotal );
9696
//! Called when a network request times out
97-
void onRequestTimedOut();
97+
void onRequestTimedOut( QNetworkReply *reply );
9898

9999
#ifndef QT_NO_SSL
100100

0 commit comments

Comments
 (0)
Please sign in to comment.