Fixed: Specify working directory for getVersionFromExecutable

This commit is contained in:
kervala 2016-11-21 16:36:12 +01:00
parent c6fa3ad931
commit 2d4ba17851
4 changed files with 7 additions and 5 deletions
code/ryzom/tools/client/ryzom_installer/src

View file

@ -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;

View file

@ -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())
{

View file

@ -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())

View file

@ -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);