Skip to content

Commit

Permalink
Fix crash in network content fetcher when run from non-main thread
Browse files Browse the repository at this point in the history
Because a QNetworkAccessManager is the parent for all QNetworkReplys
created by it, if a reply is created in a thread then we need to
ensure that this reply isn't deleted early by destruction of the
thread local QgsNetworkAcessManager instance. Work around this
by unsetting the parent for the QNetworkReplys owned by
QgsNetworkContentFetcher objects.

Fixes #19452

(cherry-picked from 7f84b6c)
  • Loading branch information
nyalldawson committed Jul 28, 2018
1 parent f20fec4 commit 1d28bbe
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/core/qgsnetworkcontentfetcher.cpp
Expand Up @@ -55,6 +55,7 @@ void QgsNetworkContentFetcher::fetchContent( const QNetworkRequest &request )
}

mReply = QgsNetworkAccessManager::instance()->get( request );
mReply->setParent( nullptr ); // we don't want thread locale QgsNetworkAccessManagers to delete the reply - we want ownership of it to belong to this object
connect( mReply, &QNetworkReply::finished, this, [ = ] { contentLoaded(); } );
connect( mReply, &QNetworkReply::downloadProgress, this, &QgsNetworkContentFetcher::downloadProgress );
}
Expand Down

0 comments on commit 1d28bbe

Please sign in to comment.