Skip to content

Commit

Permalink
Fix leaks, multiple connects in QgsFileDownloader
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 7, 2017
1 parent 826a867 commit cb1849f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/gui/qgsfiledownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,22 @@ void QgsFileDownloader::startDownload()
QgsNetworkAccessManager* nam = QgsNetworkAccessManager::instance();

QNetworkRequest request( mUrl );

if ( mReply )
{
disconnect( mReply, &QNetworkReply::readyRead, this, &QgsFileDownloader::onReadyRead );
disconnect( mReply, &QNetworkReply::finished, this, &QgsFileDownloader::onFinished );
disconnect( mReply, &QNetworkReply::downloadProgress, this, &QgsFileDownloader::onDownloadProgress );
mReply->abort();
mReply->deleteLater();
}
mReply = nam->get( request );

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 );
connect( nam, &QgsNetworkAccessManager::requestTimedOut, this, &QgsFileDownloader::onRequestTimedOut, Qt::UniqueConnection );
#ifndef QT_NO_SSL
connect( nam, &QgsNetworkAccessManager::sslErrors, this, &QgsFileDownloader::onSslErrors );
connect( nam, &QgsNetworkAccessManager::sslErrors, this, &QgsFileDownloader::onSslErrors, Qt::UniqueConnection );
#endif
if ( mGuiNotificationsEnabled )
{
Expand Down

0 comments on commit cb1849f

Please sign in to comment.