From b1de80b4169d5f60f0f1f7fd20018ba6521c293e Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Sat, 17 Sep 2022 21:22:40 +0200 Subject: Cleanup NAM more carefully This tries to fix getting stuck at exit since NAM has been switched from QThreadStorage to thread_local --- lib/networkaccessmanager.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') 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 +#include #include #include @@ -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( -- cgit v1.2.3