diff --git a/app/backend/autoupdatechecker.cpp b/app/backend/autoupdatechecker.cpp index 23a5b597..a0e8ca28 100644 --- a/app/backend/autoupdatechecker.cpp +++ b/app/backend/autoupdatechecker.cpp @@ -1,4 +1,5 @@ #include "autoupdatechecker.h" +#include "utils.h" #include #include @@ -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(); } } diff --git a/app/backend/nvcomputer.cpp b/app/backend/nvcomputer.cpp index c4e92698..983d6a16 100644 --- a/app/backend/nvcomputer.cpp +++ b/app/backend/nvcomputer.cpp @@ -1,4 +1,5 @@ #include "nvcomputer.h" +#include "utils.h" #include #include @@ -229,7 +230,7 @@ bool NvComputer::wake() success = true; } else { - qWarning() << "Send failed:" << sock.error(); + qWarning() << "Send failed:" << QSOCK_GET_ERROR(&sock); } } } diff --git a/app/backend/nvhttp.cpp b/app/backend/nvhttp.cpp index 8b70d07c..fc1a47bd 100644 --- a/app/backend/nvhttp.cpp +++ b/app/backend/nvhttp.cpp @@ -1,4 +1,5 @@ #include "nvhttp.h" +#include "utils.h" #include #include @@ -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; } diff --git a/app/main.cpp b/app/main.cpp index 22e0c972..ca76f86d 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -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; } diff --git a/app/utils.h b/app/utils.h index e2de9d42..0b90e0bb 100644 --- a/app/utils.h +++ b/app/utils.h @@ -1,8 +1,18 @@ #pragma once +#include + #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();