From 7aef03134d90c1835e556153d687abe991f00bb9 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 16 Jul 2021 10:59:45 +0200 Subject: [PATCH] Utils: Move writeData handling to QtcProcess::start() So that this doesn't only apply to runBlocking() Change-Id: I6ef7c72e13a5e214c7476ede942662a9893c843c Reviewed-by: Christian Stenger --- src/libs/utils/qtcprocess.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/libs/utils/qtcprocess.cpp b/src/libs/utils/qtcprocess.cpp index 4c55a728524..dc94c31415b 100644 --- a/src/libs/utils/qtcprocess.cpp +++ b/src/libs/utils/qtcprocess.cpp @@ -317,7 +317,14 @@ void QtcProcess::start() { d->clearForRun(); - QTC_CHECK(d->m_writeData.isEmpty()); // FIXME: Use it. + if (!d->m_writeData.isEmpty()) { + connect(d->m_process, &QProcess::started, this, [this] { + const qint64 bytesWritten = write(d->m_writeData); + QTC_CHECK(bytesWritten == d->m_writeData.size()); + d->m_process->waitForBytesWritten(); + closeWriteChannel(); // FIXME: Is this good? + }); + } if (d->m_commandLine.executable().needsDevice()) { QTC_ASSERT(s_deviceHooks.startProcessHook, return); @@ -997,11 +1004,9 @@ static bool isGuiThread() void QtcProcess::runBlocking() { // FIXME: Implement properly + if (d->m_commandLine.executable().needsDevice()) { - - // writeData ? QtcProcess::start(); - waitForFinished(); return; }; @@ -1011,12 +1016,6 @@ void QtcProcess::runBlocking() ExecuteOnDestruction logResult([this] { qCDebug(processLog) << *this; }); if (d->m_processUserEvents) { - if (!d->m_writeData.isEmpty()) { - connect(d->m_process, &QProcess::started, this, [this] { - write(d->m_writeData); - closeWriteChannel(); - }); - } setOpenMode(d->m_writeData.isEmpty() ? QIODevice::ReadOnly : QIODevice::ReadWrite); QtcProcess::start();