Skip to content

Commit cb1849f

Browse files
committed
Fix leaks, multiple connects in QgsFileDownloader
1 parent 826a867 commit cb1849f

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/gui/qgsfiledownloader.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,22 @@ void QgsFileDownloader::startDownload()
5757
QgsNetworkAccessManager* nam = QgsNetworkAccessManager::instance();
5858

5959
QNetworkRequest request( mUrl );
60-
60+
if ( mReply )
61+
{
62+
disconnect( mReply, &QNetworkReply::readyRead, this, &QgsFileDownloader::onReadyRead );
63+
disconnect( mReply, &QNetworkReply::finished, this, &QgsFileDownloader::onFinished );
64+
disconnect( mReply, &QNetworkReply::downloadProgress, this, &QgsFileDownloader::onDownloadProgress );
65+
mReply->abort();
66+
mReply->deleteLater();
67+
}
6168
mReply = nam->get( request );
6269

6370
connect( mReply, &QNetworkReply::readyRead, this, &QgsFileDownloader::onReadyRead );
6471
connect( mReply, &QNetworkReply::finished, this, &QgsFileDownloader::onFinished );
6572
connect( mReply, &QNetworkReply::downloadProgress, this, &QgsFileDownloader::onDownloadProgress );
66-
connect( nam, &QgsNetworkAccessManager::requestTimedOut, this, &QgsFileDownloader::onRequestTimedOut );
73+
connect( nam, &QgsNetworkAccessManager::requestTimedOut, this, &QgsFileDownloader::onRequestTimedOut, Qt::UniqueConnection );
6774
#ifndef QT_NO_SSL
68-
connect( nam, &QgsNetworkAccessManager::sslErrors, this, &QgsFileDownloader::onSslErrors );
75+
connect( nam, &QgsNetworkAccessManager::sslErrors, this, &QgsFileDownloader::onSslErrors, Qt::UniqueConnection );
6976
#endif
7077
if ( mGuiNotificationsEnabled )
7178
{

0 commit comments

Comments
 (0)