From 2d4ba17851bf8545757a49b36dbd5e9548aa9f28 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 21 Nov 2016 16:36:12 +0100 Subject: [PATCH] Fixed: Specify working directory for getVersionFromExecutable --- code/ryzom/tools/client/ryzom_installer/src/configfile.cpp | 2 +- .../tools/client/ryzom_installer/src/profilesdialog.cpp | 5 +++-- code/ryzom/tools/client/ryzom_installer/src/utils.cpp | 3 ++- code/ryzom/tools/client/ryzom_installer/src/utils.h | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 99f1a54a8..7d14aa223 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -693,7 +693,7 @@ int CConfigFile::compareInstallersVersion() const // if installer not found in installation directory if (!QFile::exists(installerDst)) return 1; - QString installedVersion = getVersionFromExecutable(installerDst); + QString installedVersion = getVersionFromExecutable(installerDst, getInstallationDirectory()); // if unable to get version, copy it if (installedVersion.isEmpty()) return 1; diff --git a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp index dee751b48..391e31eb9 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/profilesdialog.cpp @@ -226,20 +226,21 @@ void CProfilesDialog::updateExecutableVersion(int index) if (index < 0) return; const CProfile &profile = m_model->getProfiles()[index]; + const CServer &server = CConfigFile::getInstance()->getServer(profile.server); QString executable = profile.executable; // file empty, use default one if (executable.isEmpty()) { - executable += CConfigFile::getInstance()->getServer(profile.server).getClientFullPath(); + executable = server.getClientFullPath(); } // file doesn't exist if (executable.isEmpty() || !QFile::exists(executable)) return; // convert output to string - QString versionString = getVersionFromExecutable(executable); + QString versionString = getVersionFromExecutable(executable, server.getDirectory()); if (!versionString.isEmpty()) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp index 5ec1413e8..e52081b72 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.cpp @@ -406,7 +406,7 @@ QString appendShortcutExtension(const QString &shortcut) return shortcut + extension; } -QString getVersionFromExecutable(const QString &path) +QString getVersionFromExecutable(const QString &path, const QString &workingDirectory) { // check if file exists if (!QFile::exists(path)) @@ -426,6 +426,7 @@ QString getVersionFromExecutable(const QString &path) // launch executable with --version argument QProcess process; process.setProcessChannelMode(QProcess::MergedChannels); + process.setWorkingDirectory(workingDirectory); process.start(path, QStringList() << "--version", QIODevice::ReadOnly); if (!process.waitForStarted()) diff --git a/code/ryzom/tools/client/ryzom_installer/src/utils.h b/code/ryzom/tools/client/ryzom_installer/src/utils.h index 980826a16..aec574387 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/utils.h +++ b/code/ryzom/tools/client/ryzom_installer/src/utils.h @@ -76,7 +76,7 @@ bool resolveShortcut(const QWidget &window, const QString &shortcut, QString &pa QString appendShortcutExtension(const QString &shortcut); // launch an executable with --version parameter and parse version string -QString getVersionFromExecutable(const QString &path); +QString getVersionFromExecutable(const QString &path, const QString &workingDirectory); // write a resource in QRC to disk bool writeResource(const QString &resource, const QString &path);