From f62e29f311928f9c0cf793dd055fc74073538733 Mon Sep 17 00:00:00 2001 From: Vencislav Atanasov Date: Tue, 7 Jul 2026 23:35:43 +0300 Subject: [PATCH] rbutilqt: Simplify Utils::findExecutable() using QStandardPaths Co-authored-by: Qwen3.7-Plus Change-Id: I8f6f4003ebc7b9a4a8139f5dd4dfca3ae6cff273 --- utils/rbutilqt/base/utils.cpp | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/utils/rbutilqt/base/utils.cpp b/utils/rbutilqt/base/utils.cpp index 566782205d..1174e8e63a 100644 --- a/utils/rbutilqt/base/utils.cpp +++ b/utils/rbutilqt/base/utils.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -259,26 +260,10 @@ qulonglong Utils::filesystemSize(QString path, enum Utils::Size type) //! \brief searches for a Executable in the Environement Path QString Utils::findExecutable(QString name) { - //try autodetect tts -#if defined(Q_OS_LINUX) || defined(Q_OS_MACOS) || defined(Q_OS_OPENBSD) - QStringList path = QString(getenv("PATH")).split(":", Qt::SkipEmptyParts); -#elif defined(Q_OS_WIN) - QStringList path = QString(getenv("PATH")).split(";", Qt::SkipEmptyParts); -#endif - LOG_INFO() << "system path:" << path; - for(int i = 0; i < path.size(); i++) - { - QString executable = QDir::fromNativeSeparators(path.at(i)) + "/" + name; -#if defined(Q_OS_WIN) - executable += ".exe"; - QStringList ex = executable.split("\"", Qt::SkipEmptyParts); - executable = ex.join(""); -#endif - if(QFileInfo(executable).isExecutable()) - { - LOG_INFO() << "findExecutable: found" << executable; - return QDir::toNativeSeparators(executable); - } + QString executable = QStandardPaths::findExecutable(name); + if (!executable.isEmpty()) { + LOG_INFO() << "findExecutable: found" << executable; + return QDir::toNativeSeparators(executable); } LOG_INFO() << "findExecutable: could not find" << name; return "";