fix: merge output of stdout and stderr
This commit is contained in:
parent
bf245a7842
commit
bae58f8ddf
|
@ -1247,9 +1247,12 @@ void MainWindow::executeTool(PToolItem item)
|
||||||
QTemporaryFile file(QDir::tempPath()+QDir::separator()+"XXXXXX.bat");
|
QTemporaryFile file(QDir::tempPath()+QDir::separator()+"XXXXXX.bat");
|
||||||
file.setAutoRemove(false);
|
file.setAutoRemove(false);
|
||||||
if (file.open()) {
|
if (file.open()) {
|
||||||
file.write(escapeCommandForPlatformShell(
|
QString localizedDir=localizePath(workDir);
|
||||||
"cd", {"/d", localizePath(workDir)}
|
if (!localizedDir.isEmpty()) {
|
||||||
).toLocal8Bit() + LINE_BREAKER);
|
file.write(escapeCommandForPlatformShell(
|
||||||
|
"cd", {"/d", localizedDir}
|
||||||
|
).toLocal8Bit() + LINE_BREAKER);
|
||||||
|
}
|
||||||
file.write(escapeCommandForPlatformShell(program, params).toLocal8Bit()
|
file.write(escapeCommandForPlatformShell(program, params).toLocal8Bit()
|
||||||
+ LINE_BREAKER);
|
+ LINE_BREAKER);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
|
@ -367,11 +367,9 @@ QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const
|
||||||
} else {
|
} else {
|
||||||
process.setProcessEnvironment(env);
|
process.setProcessEnvironment(env);
|
||||||
}
|
}
|
||||||
|
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
|
process.setReadChannel(QProcess::StandardOutput);
|
||||||
process.setWorkingDirectory(workingDir);
|
process.setWorkingDirectory(workingDir);
|
||||||
process.connect(&process,&QProcess::readyReadStandardError,
|
|
||||||
[&](){
|
|
||||||
result.append(process.readAllStandardError());
|
|
||||||
});
|
|
||||||
process.connect(&process,&QProcess::readyReadStandardOutput,
|
process.connect(&process,&QProcess::readyReadStandardOutput,
|
||||||
[&](){
|
[&](){
|
||||||
result.append(process.readAllStandardOutput());
|
result.append(process.readAllStandardOutput());
|
||||||
|
@ -387,7 +385,7 @@ QByteArray runAndGetOutput(const QString &cmd, const QString& workingDir, const
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
if (errorOccurred) {
|
if (errorOccurred) {
|
||||||
result += process.errorString().toUtf8();
|
result += process.errorString().toLocal8Bit();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue