aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-12 21:08:03 +0200
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-09-12 21:08:03 +0200
commit0d0a91b4438d68c833f480f45017847829bf6088 (patch)
tree20ec3d09a96d5804a7c8ae436ef503ed556f9c85
parentf4009215b500dbae4a10d1a86bb059272e47d0cb (diff)
downloadlibquotient-0d0a91b4438d68c833f480f45017847829bf6088.tar.gz
libquotient-0d0a91b4438d68c833f480f45017847829bf6088.zip
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).
-rw-r--r--lib/networkaccessmanager.cpp13
1 files changed, 4 insertions, 9 deletions
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 <QtCore/QCoreApplication>
-#include <QtCore/QThreadStorage>
#include <QtCore/QSettings>
#include <QtNetwork/QNetworkReply>
@@ -50,9 +49,8 @@ QList<QSslError> NetworkAccessManager::ignoredSslErrors() const
void NetworkAccessManager::ignoreSslErrors(bool ignore) const
{
if (ignore) {
- connect(this, &QNetworkAccessManager::sslErrors, this, [](QNetworkReply *reply, const QList<QSslError> &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<NetworkAccessManager*> storage;
- if(!storage.hasLocalData()) {
- storage.setLocalData(new NetworkAccessManager());
- }
- return storage.localData();
+ thread_local NetworkAccessManager nam;
+ return &nam;
}
QNetworkReply* NetworkAccessManager::createRequest(