aboutsummaryrefslogtreecommitdiff
path: root/lib/networkaccessmanager.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-17 21:22:40 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-18 13:05:30 +0200
commitb1de80b4169d5f60f0f1f7fd20018ba6521c293e (patch)
treeff935ac76f2d69131081a22ef9380ae32e624e5f /lib/networkaccessmanager.cpp
parent747913f2549c1b228395192a73231b96c93f4f40 (diff)
downloadlibquotient-b1de80b4169d5f60f0f1f7fd20018ba6521c293e.tar.gz
libquotient-b1de80b4169d5f60f0f1f7fd20018ba6521c293e.zip
Cleanup NAM more carefully
This tries to fix getting stuck at exit since NAM has been switched from QThreadStorage to thread_local
Diffstat (limited to 'lib/networkaccessmanager.cpp')
-rw-r--r--lib/networkaccessmanager.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/networkaccessmanager.cpp b/lib/networkaccessmanager.cpp
index 78be89bd..44a306d1 100644
--- a/lib/networkaccessmanager.cpp
+++ b/lib/networkaccessmanager.cpp
@@ -9,6 +9,7 @@
#include "mxcreply.h"
#include <QtCore/QCoreApplication>
+#include <QtCore/QThread>
#include <QtCore/QSettings>
#include <QtNetwork/QNetworkReply>
@@ -68,8 +69,13 @@ void NetworkAccessManager::clearIgnoredSslErrors()
NetworkAccessManager* NetworkAccessManager::instance()
{
- thread_local NetworkAccessManager nam;
- return &nam;
+ thread_local auto* nam = [] {
+ auto* namInit = new NetworkAccessManager();
+ connect(QThread::currentThread(), &QThread::finished, namInit,
+ &QObject::deleteLater);
+ return namInit;
+ }();
+ return nam;
}
QNetworkReply* NetworkAccessManager::createRequest(