Use QtcProcess in FormatTask

Change-Id: Ifd46259fc4e8b68342315a227748f2ecb9acc9d6
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Jarek Kobus
2021-11-03 17:34:40 +01:00
parent 20017769c4
commit 1b772dcb27

View File

@@ -113,19 +113,19 @@ static FormatTask format(FormatTask task)
return task; return task;
case Command::PipeProcessing: { case Command::PipeProcessing: {
QProcess process; QtcProcess process;
QStringList options = task.command.options(); QStringList options = task.command.options();
options.replaceInStrings("%filename", QFileInfo(task.filePath).fileName()); options.replaceInStrings("%filename", QFileInfo(task.filePath).fileName());
options.replaceInStrings("%file", task.filePath); options.replaceInStrings("%file", task.filePath);
process.start(executable, options); process.setCommand({FilePath::fromString(executable), options});
process.setWriteData(task.sourceData.toUtf8());
process.start();
if (!process.waitForStarted(3000)) { if (!process.waitForStarted(3000)) {
task.error = QString(QT_TRANSLATE_NOOP("TextEditor", task.error = QString(QT_TRANSLATE_NOOP("TextEditor",
"Cannot call %1 or some other error occurred.")) "Cannot call %1 or some other error occurred."))
.arg(executable); .arg(executable);
return task; return task;
} }
process.write(task.sourceData.toUtf8());
process.closeWriteChannel();
if (!process.waitForFinished(5000)) { if (!process.waitForFinished(5000)) {
process.kill(); process.kill();
task.error = QString(QT_TRANSLATE_NOOP("TextEditor", task.error = QString(QT_TRANSLATE_NOOP("TextEditor",