From 4c170e0ac4691a8d50cd39ef3f4cd7309fd1b946 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 5 Oct 2019 01:54:17 +0200 Subject: [PATCH] Ref T730, reply in CAfvClient can be nullptr when called from another thread * nullptr is a normal condition * see https://discordapp.com/channels/539048679160676382/623947987822837779/629780397986676766 --- .../afv/connection/apiserverconnection.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/blackcore/afv/connection/apiserverconnection.cpp b/src/blackcore/afv/connection/apiserverconnection.cpp index e2ca3fb30..da43b8c55 100644 --- a/src/blackcore/afv/connection/apiserverconnection.cpp +++ b/src/blackcore/afv/connection/apiserverconnection.cpp @@ -65,7 +65,7 @@ namespace BlackCore request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); QEventLoop loop(sApp); - // posted in QAM thread + // posted in QAM thread, reply is nullptr if called from another thread QNetworkReply *reply = sApp->postToNetwork(request, CApplication::NoLogRequestId, QJsonDocument(obj).toJson(), { this, [ & ](QNetworkReply * nwReply) @@ -118,8 +118,9 @@ namespace BlackCore loop.exit(); } }); + Q_UNUSED(reply) - if (reply) { loop.exec(); } + loop.exec(); return m_isAuthenticated; } @@ -162,7 +163,7 @@ namespace BlackCore QEventLoop loop(sApp); QByteArray receivedData; - // posted in QAM thread + // posted in QAM thread, reply is nullptr if called from another thread QNetworkReply *reply = sApp->getFromNetwork(request, { this, [ & ](QNetworkReply * nwReply) @@ -185,8 +186,8 @@ namespace BlackCore loop.exit(); } }); + Q_UNUSED(reply) - if (!reply) { return {}; } loop.exec(); return receivedData; } @@ -198,7 +199,7 @@ namespace BlackCore QEventLoop loop(sApp); QByteArray receivedData; - // posted in QAM thread + // posted in QAM thread, reply is nullptr if called from another thread QNetworkReply *reply = sApp->postToNetwork(request, CApplication::NoLogRequestId, data, { this, [ & ](QNetworkReply * nwReply) @@ -221,8 +222,8 @@ namespace BlackCore loop.exit(); } }); + Q_UNUSED(reply) - if (!reply) { return {}; } loop.exec(); return receivedData; } @@ -244,7 +245,7 @@ namespace BlackCore request.setRawHeader("Authorization", "Bearer " + m_jwt); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); - // posted in QAM thread + // posted in QAM thread, reply is nullptr if called from another thread sApp->postToNetwork(request, CApplication::NoLogRequestId, json.toJson(), { this, [ & ](QNetworkReply * nwReply)