summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2022-01-26 12:06:30 +0200
committerKatja Marttila <katja.marttila@qt.io>2022-01-31 08:13:52 +0200
commit36227b539898a7731872c9f9c166bce05ec56601 (patch)
tree62d3d45d959db08ba9c54d6fa3cb0d26709e19a7
parentd9401513e529db6e4f5992beba84d32d531b8bfe (diff)
Do not check file existence in ConsumeOutput operation
ConsumeOutput operation executable might be a system executable. Checking with QFileInfo if the file exists or is an executable does not work then as QFileInfo expects the given path to be full. QProcess might still find the executable although QFileInfo does not. Task-number: QTIFW-2499 Change-Id: I355f24c0c97947f8247667f54f203189b3830ead Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
-rw-r--r--src/libs/installer/consumeoutputoperation.cpp28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/libs/installer/consumeoutputoperation.cpp b/src/libs/installer/consumeoutputoperation.cpp
index 7b1b22946..2de149142 100644
--- a/src/libs/installer/consumeoutputoperation.cpp
+++ b/src/libs/installer/consumeoutputoperation.cpp
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -81,19 +81,7 @@ bool ConsumeOutputOperation::performOperation()
return false;
}
- QString executablePath = arguments().at(1);
- QFileInfo executable(executablePath);
-#ifdef Q_OS_WIN
- if (!executable.exists() && executable.suffix().isEmpty())
- executable = QFileInfo(executablePath + QLatin1String(".exe"));
-#endif
-
- if (!executable.exists() || !executable.isExecutable()) {
- setError(UserDefinedError);
- setErrorString(tr("File \"%1\" does not exist or is not an executable binary.").arg(
- QDir::toNativeSeparators(executable.absoluteFilePath())));
- return false;
- }
+ QString executable = arguments().at(1);
QByteArray executableOutput;
@@ -103,17 +91,17 @@ bool ConsumeOutputOperation::performOperation()
int waitCount = 0;
while (executableOutput.isEmpty() && waitCount < 3) {
QProcess process;
- process.start(executable.absoluteFilePath(), processArguments, QIODevice::ReadOnly);
+ process.start(executable, processArguments, QIODevice::ReadOnly);
if (process.waitForFinished(10000)) {
if (process.exitStatus() == QProcess::CrashExit) {
- qCWarning(QInstaller::lcInstallerInstallLog) << executable.absoluteFilePath()
+ qCWarning(QInstaller::lcInstallerInstallLog) << executable
<< processArguments << "crashed with exit code"
<< process.exitCode() << "standard output: "
<< process.readAllStandardOutput() << "error output: "
<< process.readAllStandardError();
setError(UserDefinedError);
- setErrorString(tr("Running \"%1\" resulted in a crash.").arg(
- QDir::toNativeSeparators(executable.absoluteFilePath())));
+ setErrorString(tr("Failed to run command: \"%1\": %2").arg(
+ QDir::toNativeSeparators(executable), process.errorString()));
return false;
}
executableOutput.append(process.readAllStandardOutput());
@@ -124,7 +112,7 @@ bool ConsumeOutputOperation::performOperation()
uiDetachedWait(waitTimeInMilliSeconds);
}
if (process.state() > QProcess::NotRunning ) {
- qCWarning(QInstaller::lcInstallerInstallLog) << executable.absoluteFilePath()
+ qCWarning(QInstaller::lcInstallerInstallLog) << executable
<< "process is still running, need to kill it.";
process.kill();
}
@@ -132,7 +120,7 @@ bool ConsumeOutputOperation::performOperation()
}
if (executableOutput.isEmpty()) {
qCWarning(QInstaller::lcInstallerInstallLog) << "Cannot get any query output from executable"
- << executable.absoluteFilePath();
+ << executable;
}
core->setValue(installerKeyName, QString::fromLocal8Bit(executableOutput));
return true;