aboutsummaryrefslogtreecommitdiff
path: root/lib/networkaccessmanager.cpp
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2021-09-05 22:52:41 +0200
committerTobias Fella <fella@posteo.de>2021-09-05 22:52:41 +0200
commit67186252eac4f3890d5abae31e74efee956b2f5d (patch)
treec9ce7de67878c74700dd340fcd2d98776586d4c0 /lib/networkaccessmanager.cpp
parent4bab0f2ef2c68b478d669f90557d6bef6332e823 (diff)
downloadlibquotient-67186252eac4f3890d5abae31e74efee956b2f5d.tar.gz
libquotient-67186252eac4f3890d5abae31e74efee956b2f5d.zip
Create a NAM for each thread
Diffstat (limited to 'lib/networkaccessmanager.cpp')
-rw-r--r--lib/networkaccessmanager.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/networkaccessmanager.cpp b/lib/networkaccessmanager.cpp
index e4132957..7368de7e 100644
--- a/lib/networkaccessmanager.cpp
+++ b/lib/networkaccessmanager.cpp
@@ -5,6 +5,7 @@
#include <QtCore/QCoreApplication>
#include <QtNetwork/QNetworkReply>
+#include <QtCore/QThreadStorage>
#include "accountregistry.h"
#include "mxcreply.h"
#include "connection.h"
@@ -52,8 +53,11 @@ static NetworkAccessManager* createNam()
NetworkAccessManager* NetworkAccessManager::instance()
{
- static auto* nam = createNam();
- return nam;
+ static QThreadStorage<NetworkAccessManager *> storage;
+ if(!storage.hasLocalData()) {
+ storage.setLocalData(createNam());
+ }
+ return storage.localData();
}
NetworkAccessManager::~NetworkAccessManager() = default;