Multi-threaded usage of QgsNetworkAccessManager #22194
Labels
API
API improvement only, no visible user interface changes
Bug
Either a bug report, or a bug fix. Let's hope for the latter!
Crash/Data Corruption
Author Name: Patrick Valsecchi (Patrick Valsecchi)
Original Redmine Issue: 14192
Affected QGIS version: master
Redmine category:network
QgsNetworkAccessManager has a singleton that is used all over the place. The problem is that "all over the place" means from different threads and according to the Qt documentation, QNetworkAccessManager is only reentrant (thread safe only if threads are using different instances).
This problem can easily be proven by adding a check in this method:
QGIS will crash quickly when you start it:
I propose we fix it using a QThreadStorage like that:
And we make the constructor private to force the code using it to go through instance().
Related issue(s): #22382 (relates)
Redmine related issue(s): 14401
The text was updated successfully, but these errors were encountered: