lint + fix Linux versions (missing declaration)

This commit is contained in:
tooomm 2026-07-08 16:21:06 +02:00
parent 1675e318cc
commit 42d001ee6a
2 changed files with 12 additions and 9 deletions

View file

@ -2,7 +2,6 @@
#include "version_string.h" #include "version_string.h"
#include <optional>
#include <QJsonArray> #include <QJsonArray>
#include <QJsonDocument> #include <QJsonDocument>
#include <QJsonObject> #include <QJsonObject>
@ -11,6 +10,7 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QSysInfo> #include <QSysInfo>
#include <QtGlobal> #include <QtGlobal>
#include <optional>
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
#include <sys/sysctl.h> #include <sys/sysctl.h>
@ -47,6 +47,8 @@ void ReleaseChannel::checkForUpdates()
// Different release channel checking functions for different operating systems // Different release channel checking functions for different operating systems
std::optional<int> ReleaseChannel::getTargetVersionForCurrentOS(const QString &fileName) std::optional<int> ReleaseChannel::getTargetVersionForCurrentOS(const QString &fileName)
{ {
const QRegularExpression *regex = nullptr;
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
const bool isIntel = [] { const bool isIntel = [] {
// QSysInfo does not go through translation layers // QSysInfo does not go through translation layers
@ -58,12 +60,14 @@ std::optional<int> ReleaseChannel::getTargetVersionForCurrentOS(const QString &f
} }
return false; return false;
}(); }();
static const QRegularExpression macIntelRegex(R"(macOS(\d+)_Intel\.[^.]+$)", QRegularExpression::CaseInsensitiveOption); static const QRegularExpression macIntelRegex(R"(macOS(\d+)_Intel\.[^.]+$)",
QRegularExpression::CaseInsensitiveOption);
static const QRegularExpression macArmRegex(R"(macOS(\d+)\.[^.]+$)", QRegularExpression::CaseInsensitiveOption); static const QRegularExpression macArmRegex(R"(macOS(\d+)\.[^.]+$)", QRegularExpression::CaseInsensitiveOption);
const QRegularExpression &regex = isIntel ? macIntelRegex : macArmRegex; regex = isIntel ? &macIntelRegex : &macArmRegex;
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
static const QRegularExpression regex(R"(Win(?:dows)?(\d+)\.[^.]+$)", QRegularExpression::CaseInsensitiveOption); static const QRegularExpression winRegex(R"(Win(?:dows)?(\d+)\.[^.]+$)", QRegularExpression::CaseInsensitiveOption);
regex = &winRegex;
#else // if the OS doesn't fit one of the above #defines, then it will never match #else // if the OS doesn't fit one of the above #defines, then it will never match
Q_UNUSED(fileName); Q_UNUSED(fileName);
@ -71,7 +75,7 @@ std::optional<int> ReleaseChannel::getTargetVersionForCurrentOS(const QString &f
#endif #endif
const int systemVersion = QSysInfo::productVersion().split('.').first().toInt(); const int systemVersion = QSysInfo::productVersion().split('.').first().toInt();
auto match = regex.match(fileName); auto match = regex->match(fileName);
if (!match.hasMatch()) { if (!match.hasMatch()) {
return std::nullopt; return std::nullopt;
} }
@ -100,8 +104,7 @@ QString ReleaseChannel::findBestDownloadUrl(const QVariantList &assets)
} }
} }
if (!bestUrl.isEmpty()) { if (!bestUrl.isEmpty()) {
qCInfo(ReleaseChannelLog) qCInfo(ReleaseChannelLog) << "Best compatible asset=" << bestUrl;
<< "Best compatible asset=" << bestUrl;
} }
return bestUrl; return bestUrl;
} }
@ -152,7 +155,7 @@ void StableReleaseChannel::releaseListFinished()
if (resultMap.contains("assets")) { if (resultMap.contains("assets")) {
auto url = findBestDownloadUrl(resultMap["assets"].toList()); auto url = findBestDownloadUrl(resultMap["assets"].toList());
if (!url.isEmpty()) { if (!url.isEmpty()) {
lastRelease->setDownloadUrl(url); lastRelease->setDownloadUrl(url);
} }
} }

View file

@ -7,12 +7,12 @@
#ifndef RELEASECHANNEL_H #ifndef RELEASECHANNEL_H
#define RELEASECHANNEL_H #define RELEASECHANNEL_H
#include <optional>
#include <QDate> #include <QDate>
#include <QLoggingCategory> #include <QLoggingCategory>
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QVariantMap> #include <QVariantMap>
#include <optional>
#include <utility> #include <utility>
inline Q_LOGGING_CATEGORY(ReleaseChannelLog, "release_channel"); inline Q_LOGGING_CATEGORY(ReleaseChannelLog, "release_channel");