simplify feeding synchronous processes

QProcess is fully buffered, so there is no point in trying to feed it
chunk-wise.

amends 25264d9b.

Change-Id: Ie1a32a6ac56f8e21a452b26dfaca4237d3f08d9f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Oswald Buddenhagen
2020-12-09 14:03:46 +01:00
parent 65fb83089e
commit 891c797c4b

View File

@@ -482,16 +482,7 @@ SynchronousProcessResponse SynchronousProcess::run(const CommandLine &cmd,
d->m_process.setProgram(cmd.executable().toString());
d->m_process.setArguments(cmd.splitArguments());
connect(&d->m_process, &QProcess::started, this, [this, writeData] {
if (!writeData.isEmpty()) {
int pos = 0;
int sz = writeData.size();
do {
d->m_process.waitForBytesWritten();
auto res = d->m_process.write(writeData.constData() + pos, sz - pos);
if (res > 0) pos += res;
} while (pos < sz);
d->m_process.waitForBytesWritten();
}
d->m_process.write(writeData);
d->m_process.closeWriteChannel();
});
d->m_process.start(writeData.isEmpty() ? QIODevice::ReadOnly : QIODevice::ReadWrite);