Skip to content
Browse files
Fix crash in network content fetcher when run from non-main thread
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 1d28bbe0cecba01ac596b3eb89f0c70c226822ab
Showing with 1 addition and 0 deletions.
  1. +1 −0 src/core/qgsnetworkcontentfetcher.cpp
@@ -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 );

0 comments on commit 1d28bbe

Please sign in to comment.