From 0d0a91b4438d68c833f480f45017847829bf6088 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 12 Sep 2022 21:08:03 +0200 Subject: NetworkAccessManager: QThreadStorage -> thread_local It's more straightforward in usage and less prone to leaks (QThreadStorage doesn't delete objects when on non-main thread). --- lib/networkaccessmanager.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/networkaccessmanager.cpp b/lib/networkaccessmanager.cpp index 38ab07cc..78be89bd 100644 --- a/lib/networkaccessmanager.cpp +++ b/lib/networkaccessmanager.cpp @@ -9,7 +9,6 @@ #include "mxcreply.h" #include -#include #include #include @@ -50,9 +49,8 @@ QList NetworkAccessManager::ignoredSslErrors() const void NetworkAccessManager::ignoreSslErrors(bool ignore) const { if (ignore) { - connect(this, &QNetworkAccessManager::sslErrors, this, [](QNetworkReply *reply, const QList &errors) { - reply->ignoreSslErrors(); - }); + connect(this, &QNetworkAccessManager::sslErrors, this, + [](QNetworkReply* reply) { reply->ignoreSslErrors(); }); } else { disconnect(this, &QNetworkAccessManager::sslErrors, this, nullptr); } @@ -70,11 +68,8 @@ void NetworkAccessManager::clearIgnoredSslErrors() NetworkAccessManager* NetworkAccessManager::instance() { - static QThreadStorage storage; - if(!storage.hasLocalData()) { - storage.setLocalData(new NetworkAccessManager()); - } - return storage.localData(); + thread_local NetworkAccessManager nam; + return &nam; } QNetworkReply* NetworkAccessManager::createRequest( -- cgit v1.2.3