diff --git a/src/net/toxme.cpp b/src/net/toxme.cpp index 79fe81c1b..9b384de6b 100644 --- a/src/net/toxme.cpp +++ b/src/net/toxme.cpp @@ -38,18 +38,17 @@ QByteArray Toxme::makeJsonRequest(QString url, QString json, QNetworkReply::Netw request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); QNetworkReply* reply = netman.post(request,json.toUtf8()); - while (reply->isRunning()) { - error = reply->error(); - if (error) - break; - - reply->waitForReadyRead(100); + while (!reply->isFinished()) + { qApp->processEvents(); } error = reply->error(); if (error) - qWarning() << "makeJsonRequest: A network error occured:" << error.errorString(); + { + qWarning() << "makeJsonRequest: A network error occured:" << reply->errorString(); + return QByteArray(); + } return reply->readAll(); } @@ -65,18 +64,17 @@ QByteArray Toxme::getServerPubkey(QString url, QNetworkReply::NetworkError &erro request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json"); QNetworkReply* reply = netman.get(request); - while (reply->isRunning()) { - error = reply->error(); - if (error) - break; - - reply->waitForReadyRead(100); + while (!reply->isFinished()) + { qApp->processEvents(); } error = reply->error(); if (error) - qWarning() << "getServerPubkey: A network error occured:" << error.errorString(); + { + qWarning() << "getServerPubkey: A network error occured:" << reply->errorString(); + return QByteArray(); + } // Extract key static const QByteArray pattern{"key\":\""};