From df54a76a941c8e5649d9887b06fce656b167444d Mon Sep 17 00:00:00 2001 From: Alexander Yee Date: Mon, 10 Aug 2026 23:17:31 -0700 Subject: [PATCH 1/5] Migrate more Linux GlobalAutoPaths off Qt. --- .../CommonFramework/GlobalAutoPaths.cpp | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp index 21605cca11..078f3041e5 100644 --- a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp +++ b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp @@ -74,26 +74,27 @@ Filesystem::Path get_application_base_dir_path(){ return std::filesystem::absolute(path).parent_path().lexically_normal(); } } - QByteArray appDirBytes = qgetenv("APPDIR"); - if (!appDirBytes.isEmpty()){ - QString appDir = QString::fromUtf8(appDirBytes); - QFile mountinfo(QStringLiteral("/proc/self/mountinfo")); - if (mountinfo.open(QIODevice::ReadOnly | QIODevice::Text)){ - while (!mountinfo.atEnd()){ - QString line = QString::fromUtf8(mountinfo.readLine()).trimmed(); - int dashSep = line.indexOf(QStringLiteral(" - ")); - if (dashSep < 0){ - continue; - } - QStringList pre = line.left(dashSep).split(u' ', Qt::SkipEmptyParts); - QStringList post = line.mid(dashSep + 3).split(u' ', Qt::SkipEmptyParts); - if (pre.size() < 5 || post.size() < 2){ - continue; - } - QString mountPoint = pre[4].replace(QStringLiteral("\\040"), QStringLiteral(" ")); - QString source = post[1].replace(QStringLiteral("\\040"), QStringLiteral(" ")); - if (mountPoint == appDir && source.endsWith(QStringLiteral(".AppImage"))){ - return QDir::cleanPath(QFileInfo(source).dir().absolutePath()).toStdString(); + { + char* app_dir = std::getenv("APPDIR"); + if (app_dir != nullptr){ + QFile mountinfo(QStringLiteral("/proc/self/mountinfo")); + if (mountinfo.open(QIODevice::ReadOnly | QIODevice::Text)){ + while (!mountinfo.atEnd()){ + QString line = QString::fromUtf8(mountinfo.readLine()).trimmed(); + int dashSep = line.indexOf(QStringLiteral(" - ")); + if (dashSep < 0){ + continue; + } + QStringList pre = line.left(dashSep).split(u' ', Qt::SkipEmptyParts); + QStringList post = line.mid(dashSep + 3).split(u' ', Qt::SkipEmptyParts); + if (pre.size() < 5 || post.size() < 2){ + continue; + } + QString mountPoint = pre[4].replace(QStringLiteral("\\040"), QStringLiteral(" ")); + QString source = post[1].replace(QStringLiteral("\\040"), QStringLiteral(" ")); + if (mountPoint == QString::fromUtf8(appDir) && source.endsWith(QStringLiteral(".AppImage"))){ + return QDir::cleanPath(QFileInfo(source).dir().absolutePath()).toStdString(); + } } } } From c670c9fdcfec6aafc87960667951814ab5f867aa Mon Sep 17 00:00:00 2001 From: Alexander Yee Date: Mon, 10 Aug 2026 23:26:10 -0700 Subject: [PATCH 2/5] nope --- SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp index 078f3041e5..024c65ee5e 100644 --- a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp +++ b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp @@ -92,7 +92,7 @@ Filesystem::Path get_application_base_dir_path(){ } QString mountPoint = pre[4].replace(QStringLiteral("\\040"), QStringLiteral(" ")); QString source = post[1].replace(QStringLiteral("\\040"), QStringLiteral(" ")); - if (mountPoint == QString::fromUtf8(appDir) && source.endsWith(QStringLiteral(".AppImage"))){ + if (mountPoint == QString::fromUtf8(app_dir) && source.endsWith(QStringLiteral(".AppImage"))){ return QDir::cleanPath(QFileInfo(source).dir().absolutePath()).toStdString(); } } From ae25a85391a2e49043dced2248a1ce1aa05971c2 Mon Sep 17 00:00:00 2001 From: Alexander Yee Date: Tue, 11 Aug 2026 00:59:19 -0700 Subject: [PATCH 3/5] Migrate more Linux GlobalAutoPaths off Qt. (part 2) --- .../Source/CommonFramework/GlobalAutoPaths.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp index 024c65ee5e..88c7e6c9a9 100644 --- a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp +++ b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp @@ -77,16 +77,17 @@ Filesystem::Path get_application_base_dir_path(){ { char* app_dir = std::getenv("APPDIR"); if (app_dir != nullptr){ - QFile mountinfo(QStringLiteral("/proc/self/mountinfo")); - if (mountinfo.open(QIODevice::ReadOnly | QIODevice::Text)){ - while (!mountinfo.atEnd()){ - QString line = QString::fromUtf8(mountinfo.readLine()).trimmed(); - int dashSep = line.indexOf(QStringLiteral(" - ")); + std::ifstream mount_info(Filesystem::Path("/proc/self/mountinfo").stdpath()); + if (mount_info.is_open()){ + std::string line; + while (std::getline(mount_info, line)){ + QString qline = QString::fromStdString(line); + int dashSep = qline.indexOf(QStringLiteral(" - ")); if (dashSep < 0){ continue; } - QStringList pre = line.left(dashSep).split(u' ', Qt::SkipEmptyParts); - QStringList post = line.mid(dashSep + 3).split(u' ', Qt::SkipEmptyParts); + QStringList pre = qline.left(dashSep).split(u' ', Qt::SkipEmptyParts); + QStringList post = qline.mid(dashSep + 3).split(u' ', Qt::SkipEmptyParts); if (pre.size() < 5 || post.size() < 2){ continue; } From 2d4255e479f607ee5d903e08d8d2512547453ef5 Mon Sep 17 00:00:00 2001 From: Alexander Yee Date: Tue, 11 Aug 2026 01:15:34 -0700 Subject: [PATCH 4/5] fix --- SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp index 88c7e6c9a9..dafb111972 100644 --- a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp +++ b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp @@ -12,6 +12,7 @@ #include #include #include "Common/Cpp/Filesystem/Filesystem.h" +#include "Common/Cpp/Filesystem/FileIO.h" #include "GlobalAutoPaths.h" #ifdef __linux__ From 77d8d47d687dcfd1e26df26839265876ec5fdc7f Mon Sep 17 00:00:00 2001 From: Alexander Yee Date: Tue, 11 Aug 2026 01:32:39 -0700 Subject: [PATCH 5/5] nope --- SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp index dafb111972..e32fcf63c2 100644 --- a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp +++ b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp @@ -12,11 +12,12 @@ #include #include #include "Common/Cpp/Filesystem/Filesystem.h" -#include "Common/Cpp/Filesystem/FileIO.h" #include "GlobalAutoPaths.h" #ifdef __linux__ #include +#include +#include "Common/Cpp/Filesystem/FileIO.h" #endif //#include