diff options
author | Robert Griebl <robert.griebl@pelagicore.com> | 2017-11-20 18:09:00 +0100 |
---|---|---|
committer | Robert Griebl <robert.griebl@pelagicore.com> | 2017-11-21 00:02:51 +0000 |
commit | 81d0a0f6dd6c78e2ddd0fff5d43b9ab1285bffbc (patch) | |
tree | 31d9104cf958e9793448d012f2da9edcb21ae934 | |
parent | 851d2f837fcfd52dbac568beb3ab83bd9508521f (diff) | |
download | qtapplicationmanager-81d0a0f6dd6c78e2ddd0fff5d43b9ab1285bffbc.tar.gz |
Improve launcher binary detection
In addition to the already checked paths, also look in $PATH. On error,
output where the AM was looking for.
Change-Id: I64d1511540a1d9b4e5cc9386f7470d83c0fc330b
Reviewed-by: Thomas Senyk <thomas.senyk@pelagicore.com>
-rw-r--r-- | src/manager-lib/nativeruntime.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/manager-lib/nativeruntime.cpp b/src/manager-lib/nativeruntime.cpp index 2b9b7fdc..f10a20fa 100644 --- a/src/manager-lib/nativeruntime.cpp +++ b/src/manager-lib/nativeruntime.cpp @@ -191,11 +191,20 @@ bool NativeRuntime::attachApplicationToQuickLauncher(const Application *app) bool NativeRuntime::initialize() { if (m_needsLauncher) { - static const QVector<QString> possibleLocations = { - QCoreApplication::applicationDirPath(), - QLibraryInfo::location(QLibraryInfo::BinariesPath), - qApp->property("_am_build_dir").toString() + qSL("/bin") // set by main.cpp - }; + static QVector<QString> possibleLocations; + if (possibleLocations.isEmpty()) { + // try the main binaries directory + possibleLocations.append(QCoreApplication::applicationDirPath()); + // try Qt's bin folder + possibleLocations.append(QLibraryInfo::location(QLibraryInfo::BinariesPath)); + // try the AM's build directory + possibleLocations.append(qApp->property("_am_build_dir").toString() + qSL("/bin")); // set by main.cpp + // if everything fails, try to locate it in $PATH + const auto paths = qgetenv("PATH").split(QDir::listSeparator().toLatin1()); + for (auto path : paths) + possibleLocations.append(QString::fromLocal8Bit(path)); + } + const QString launcherName = qSL("/appman-launcher-") + manager()->identifier(); for (const QString &possibleLocation : possibleLocations) { QFileInfo fi(possibleLocation + launcherName); @@ -207,7 +216,8 @@ bool NativeRuntime::initialize() return true; } } - qCWarning(LogSystem) << "Could not find an" << launcherName.mid(1) << "executable."; + qCWarning(LogSystem) << "Could not find an" << launcherName.mid(1) << "executable in any of:\n" + << possibleLocations; return false; } else { if (!m_app) |