Fix build with Qt 5.15

This commit is contained in:
Cameron Gutman 2020-02-24 17:39:24 -08:00
parent 979de190dc
commit 10dae7482c
5 changed files with 22 additions and 9 deletions

View File

@ -1,4 +1,5 @@
#include "autoupdatechecker.h"
#include "utils.h"
#include <QNetworkReply>
#include <QJsonDocument>
@ -61,7 +62,7 @@ void AutoUpdateChecker::handleUpdateCheckRequestFinished(QNetworkReply* reply)
{
Q_ASSERT(reply->isFinished());
if (reply->error() == QNetworkReply::NoError) {
if (QNETREPLY_GET_ERROR(reply) == QNetworkReply::NoError) {
QTextStream stream(reply);
stream.setCodec("UTF-8");
@ -154,7 +155,7 @@ void AutoUpdateChecker::handleUpdateCheckRequestFinished(QNetworkReply* reply)
<< QSysInfo::buildCpuArchitecture() << getPlatform();
}
else {
qWarning() << "Update checking failed with error: " << reply->error();
qWarning() << "Update checking failed with error: " << QNETREPLY_GET_ERROR(reply);
reply->deleteLater();
}
}

View File

@ -1,4 +1,5 @@
#include "nvcomputer.h"
#include "utils.h"
#include <QUdpSocket>
#include <QHostInfo>
@ -229,7 +230,7 @@ bool NvComputer::wake()
success = true;
}
else {
qWarning() << "Send failed:" << sock.error();
qWarning() << "Send failed:" << QSOCK_GET_ERROR(&sock);
}
}
}

View File

@ -1,4 +1,5 @@
#include "nvhttp.h"
#include "utils.h"
#include <Limelight.h>
#include <QDebug>
@ -488,26 +489,26 @@ NvHTTP::openConnection(QUrl baseUrl,
m_Nam.clearAccessCache();
// Handle error
if (reply->error() != QNetworkReply::NoError)
if (QNETREPLY_GET_ERROR(reply) != QNetworkReply::NoError)
{
if (logLevel >= NvLogLevel::NVLL_ERROR) {
qWarning() << command << " request failed with error " << reply->error();
qWarning() << command << " request failed with error " << QNETREPLY_GET_ERROR(reply);
}
if (reply->error() == QNetworkReply::SslHandshakeFailedError) {
if (QNETREPLY_GET_ERROR(reply) == QNetworkReply::SslHandshakeFailedError) {
// This will trigger falling back to HTTP for the serverinfo query
// then pairing again to get the updated certificate.
GfeHttpResponseException exception(401, "Server certificate mismatch");
delete reply;
throw exception;
}
else if (reply->error() == QNetworkReply::OperationCanceledError) {
else if (QNETREPLY_GET_ERROR(reply) == QNetworkReply::OperationCanceledError) {
QtNetworkReplyException exception(QNetworkReply::TimeoutError, "Request timed out");
delete reply;
throw exception;
}
else {
QtNetworkReplyException exception(reply->error(), reply->errorString());
QtNetworkReplyException exception(QNETREPLY_GET_ERROR(reply), reply->errorString());
delete reply;
throw exception;
}

View File

@ -74,7 +74,7 @@ void logToLoggerStream(QString& message)
return;
}
else if (s_LogLinesWritten == MAX_LOG_LINES) {
s_LoggerStream << "Log size limit reached!" << endl;
s_LoggerStream << "Log size limit reached!" << Qt::endl;
s_LogLimitReached = true;
return;
}

View File

@ -1,8 +1,18 @@
#pragma once
#include <QtGlobal>
#define THROW_BAD_ALLOC_IF_NULL(x) \
if ((x) == nullptr) throw std::bad_alloc()
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
#define QNETREPLY_GET_ERROR(r) ((r)->networkError())
#define QSOCK_GET_ERROR(s) ((s)->socketError())
#else
#define QNETREPLY_GET_ERROR(r) ((r)->error())
#define QSOCK_GET_ERROR(s) ((s)->error())
#endif
namespace WMUtils {
bool isRunningX11();
bool isRunningWayland();