Skip to content

Commit 1d28bbe

Browse files
committedJul 28, 2018
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)
1 parent f20fec4 commit 1d28bbe

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed
 

‎src/core/qgsnetworkcontentfetcher.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void QgsNetworkContentFetcher::fetchContent( const QNetworkRequest &request )
5555
}
5656

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

0 commit comments

Comments
 (0)
Please sign in to comment.