Use refactored ProcessMode

This patch needs to be applied together with the parent change.

There are 3 basic cases:
1. The user doesn't write anything to the write channel:
   You don't need to call closeWriteChannel manually anymore.
   By default the QtcProcess you create is in ProcessMode::Reader mode.
   Internally it opens the process in ReadOnly mode and
   closes the write channel just after starting.
2. The user writes some initial data (after being started)
   and then closes the write channel:
   All what is needed now it to set the write data
   (QtcProcess::setWriteData) before calling start.
   You also use the default ProcessMode::Reader mode.
   Internally it opens the process in ReadWrite mode
   and writes the writeData asynchonously when the process
   already started. After writing the data it closes the
   write channel automatically.
3. The user writes the data also after calling start.
   All you need now is to create a process with
   ProcessMode::Writer mode. In this mode the write
   channel is not closed.
   Internally it opens the process in ReadWrite mode
   as some writers also read the data from the process.

All the code base is adapted here to the above rules.

Change-Id: Id103019d1d71a3012fd1eade226fe96b9aaa48c2
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Jarek Kobus
2021-08-07 11:41:23 +02:00
parent 25f585227f
commit d22505c41f
23 changed files with 20 additions and 91 deletions

View File

@@ -122,6 +122,7 @@ private:
DockerDeviceProcess::DockerDeviceProcess(const QSharedPointer<const IDevice> &device,
QObject *parent)
: DeviceProcess(device, parent)
, m_process(ProcessMode::Writer)
{
}
@@ -1449,7 +1450,7 @@ void DockerDevice::runProcess(QtcProcess &process) const
CommandLine cmd{"docker", {"exec"}};
if (!workingDir.isEmpty())
cmd.addArgs({"-w", workingDir.path()});
if (process.keepsWriteChannelOpen())
if (process.processMode() == ProcessMode::Writer)
cmd.addArg("-i");
if (env.size() != 0 && d->m_accessible != DockerDevicePrivate::Accessible) {
process.unsetEnvironment();