From df54a76a941c8e5649d9887b06fce656b167444d Mon Sep 17 00:00:00 2001 From: Alexander Yee Date: Mon, 10 Aug 2026 23:17:31 -0700 Subject: [PATCH 1/2] 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/2] 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(); } }