Skip to content

Commit 19e810d

Browse files
Zhao, AndrewZhao, Andrew
Zhao, Andrew
authored and
Zhao, Andrew
committed
Feat: add exit code
1 parent 990908f commit 19e810d

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/libs/installer/consumeoutputoperation.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,41 +89,49 @@ bool ConsumeOutputOperation::performOperation()
8989
const QStringList processArguments = arguments().mid(2);
9090
// in some cases it is not runable, because another process is blocking it(filewatcher ...)
9191
int waitCount = 0;
92+
int _exitCode = 0;
9293
while (executableOutput.isEmpty() && waitCount < 3) {
9394
QProcess process;
9495
process.setProcessChannelMode(QProcess::MergedChannels);
9596
process.start(executable, processArguments, QIODevice::ReadOnly);
9697
if (process.waitForFinished(10000)) {
9798
if (process.exitStatus() == QProcess::CrashExit) {
9899
qCWarning(QInstaller::lcInstallerInstallLog) << executable
99-
<< processArguments << "crashed with exit code"
100-
<< process.exitCode() << "standard output: "
101-
<< process.readAllStandardOutput() << "error output: "
102-
<< process.readAllStandardError();
100+
<< processArguments << "crashed with exit code"
101+
<< process.exitCode() << "standard output: "
102+
<< process.readAllStandardOutput() << "error output: "
103+
<< process.readAllStandardError();
103104
setError(UserDefinedError);
104105
setErrorString(tr("Failed to run command: \"%1\": %2").arg(
105106
QDir::toNativeSeparators(executable), process.errorString()));
107+
108+
_exitCode = process.exitCode();
109+
core->setValue(installerKeyName + QStringLiteral("ExitCode"), (const QString)QString::number (_exitCode));
106110
return false;
107111
}
112+
113+
_exitCode = process.exitCode();
108114
executableOutput.append(process.readAllStandardOutput());
109115
}
116+
110117
if (executableOutput.isEmpty()) {
111118
++waitCount;
112119
static const int waitTimeInMilliSeconds = 500;
113120
uiDetachedWait(waitTimeInMilliSeconds);
114121
}
115122
if (process.state() > QProcess::NotRunning ) {
116123
qCWarning(QInstaller::lcInstallerInstallLog) << executable
117-
<< "process is still running, need to kill it.";
124+
<< "process is still running, need to kill it.";
118125
process.kill();
119126
}
120127

121128
}
122129
if (executableOutput.isEmpty()) {
123130
qCWarning(QInstaller::lcInstallerInstallLog) << "Cannot get any query output from executable"
124-
<< executable;
131+
<< executable;
125132
}
126133
core->setValue(installerKeyName, QString::fromLocal8Bit(executableOutput.trimmed()));
134+
core->setValue(installerKeyName + QStringLiteral("ExitCode"), (const QString)QString::number (_exitCode));
127135
return true;
128136
}
129137

0 commit comments

Comments
 (0)