From 457988f4c51d341f71a3cec19aec3535f9a5480a Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Wed, 12 Aug 2026 18:18:46 +0000 Subject: [PATCH 2/4] Qt4: replace QStandardPaths/QSysInfo::buildCpuArchitecture with portable equivalents QStandardPaths and QSysInfo::buildCpuArchitecture() don't exist on Qt4. - FileLogger.h: version-gate the app-data-location lookup, falling back to QDesktopServices::storageLocation() (removed in Qt6, so Qt5/6 keep using QStandardPaths). - vpninfo.cpp: the Linux/FreeBSD user-agent OS strings only needed the pointer size, so use sizeof(void*) directly instead of a Qt API at all (these branches are dead code on the macOS target, but fixed for portability). Part of Qt4 buildability work for the macOS PowerPC port. --- src/FileLogger.h | 14 +++++++++++++- src/vpninfo.cpp | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/FileLogger.h b/src/FileLogger.h index 0ccbd2c..3f180fe 100644 --- a/src/FileLogger.h +++ b/src/FileLogger.h @@ -3,15 +3,27 @@ #include "spdlog/sinks/rotating_file_sink.h" #include +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include +#else +/* QStandardPaths does not exist on Qt4; QDesktopServices::storageLocation() + * covers the same need and was removed in Qt6. */ +#include +#endif #include "logger.h" +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) +#define OCG_APP_DATA_LOCATION QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) +#else +#define OCG_APP_DATA_LOCATION QDesktopServices::storageLocation(QDesktopServices::DataLocation) +#endif + class FileLogger : public QObject { Q_OBJECT public: explicit FileLogger(QObject* parent = nullptr, - const QString& logPath = QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)).arg("logs"), + const QString& logPath = QString("%1/%2").arg(OCG_APP_DATA_LOCATION).arg("logs"), const size_t logSize = 1024 * 1024, const size_t logCount = 5); ~FileLogger(); diff --git a/src/vpninfo.cpp b/src/vpninfo.cpp index d5806c4..75bfea9 100644 --- a/src/vpninfo.cpp +++ b/src/vpninfo.cpp @@ -543,9 +543,9 @@ int VpnInfo::connect() #elif defined Q_OS_OSX const QString osName{ "mac-intel" }; #elif defined Q_OS_LINUX - const QString osName = QString("linux%1").arg(QSysInfo::buildCpuArchitecture() == "i386" ? "" : "-64").toStdString().c_str(); + const QString osName = QString("linux%1").arg(sizeof(void*) == 4 ? "" : "-64").toStdString().c_str(); #elif defined Q_OS_FREEBSD - const QString osName = QString("freebsd%1").arg(QSysInfo::buildCpuArchitecture() == "i386" ? "" : "-64").toStdString().c_str(); + const QString osName = QString("freebsd%1").arg(sizeof(void*) == 4 ? "" : "-64").toStdString().c_str(); #else #error Define OS string of other platforms... #endif -- 2.43.0