From 58a90ad8893749e6b406247be774f51363b3af08 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 7 Mar 2022 06:04:26 +0400 Subject: [PATCH] Try to find executable in PATH if argv0 doesn't have path --- base/platform/linux/base_file_utilities_linux.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/base/platform/linux/base_file_utilities_linux.cpp b/base/platform/linux/base_file_utilities_linux.cpp index aa65e5e..c9960a8 100644 --- a/base/platform/linux/base_file_utilities_linux.cpp +++ b/base/platform/linux/base_file_utilities_linux.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #ifndef DESKTOP_APP_DISABLE_DBUS_INTEGRATION @@ -210,7 +210,18 @@ QString CurrentExecutablePath(int argc, char *argv[]) { } // Fallback to the first command line argument. - return argc ? QFile::decodeName(argv[0]) : QString(); + if (argc) { + const auto argv0 = QFile::decodeName(argv[0]); + if (!argv0.isEmpty() && !QFileInfo::exists(argv0)) { + const auto argv0InPath = QStandardPaths::findExecutable(argv0); + if (!argv0InPath.isEmpty()) { + return argv0InPath; + } + } + return argv0; + } + + return QString(); } void RemoveQuarantine(const QString &path) {