summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_win.cpp
diff options
context:
space:
mode:
authorAlex Trotsenko <alex1973tr@gmail.com>2020-12-22 18:45:55 +0200
committerAlex Trotsenko <alex1973tr@gmail.com>2020-12-31 09:34:54 +0200
commit1fb9c5348e3f7d4dd80e5b924aaca93632c651f9 (patch)
treeec320f33446073cc8a6c57a50752a390dae7851b /src/corelib/io/qprocess_win.cpp
parent8be9fb66f7872dc1e7a6ad729459be66ee5a1540 (diff)
QProcess: consolidate channel management
We have the same channel forwarding, redirecting, and merging rules for all platforms. This makes it possible to introduce the openChannels() function, which consolidates the logic and performs high-level general processing of the channels configuration properties. Change-Id: Id3574fc42a56829328369b6a1a6ec9c95fce8eca Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io/qprocess_win.cpp')
-rw-r--r--src/corelib/io/qprocess_win.cpp29
1 files changed, 4 insertions, 25 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 886c4e8587..c9223443e2 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -180,40 +180,23 @@ static bool qt_create_pipe(Q_PIPE *pipe, bool isInputPipe)
/*
Create the pipes to a QProcessPrivate::Channel.
-
- This function must be called in order: stdin, stdout, stderr
*/
bool QProcessPrivate::openChannel(Channel &channel)
{
Q_Q(QProcess);
- if (&channel == &stderrChannel && processChannelMode == QProcess::MergedChannels)
- return true;
-
switch (channel.type) {
case Channel::Normal: {
// we're piping this channel to our own process
- if (&channel == &stdinChannel) {
- return inputChannelMode == QProcess::ForwardedInputChannel
- || qt_create_pipe(channel.pipe, true);
- }
+ if (&channel == &stdinChannel)
+ return qt_create_pipe(channel.pipe, true);
if (&channel == &stdoutChannel) {
- if (processChannelMode == QProcess::ForwardedChannels
- || processChannelMode == QProcess::ForwardedOutputChannel) {
- return true;
- }
-
if (!stdoutChannel.reader) {
stdoutChannel.reader = new QWindowsPipeReader(q);
q->connect(stdoutChannel.reader, SIGNAL(readyRead()), SLOT(_q_canReadStandardOutput()));
}
} else /* if (&channel == &stderrChannel) */ {
- if (processChannelMode == QProcess::ForwardedChannels
- || processChannelMode == QProcess::ForwardedErrorChannel) {
- return true;
- }
-
if (!stderrChannel.reader) {
stderrChannel.reader = new QWindowsPipeReader(q);
q->connect(stderrChannel.reader, SIGNAL(readyRead()), SLOT(_q_canReadStandardError()));
@@ -545,9 +528,7 @@ void QProcessPrivate::startProcess()
q->setProcessState(QProcess::Starting);
- if (!openChannel(stdinChannel) ||
- !openChannel(stdoutChannel) ||
- !openChannel(stderrChannel)) {
+ if (!openChannels()) {
QString errorString = QProcess::tr("Process failed to start: %1").arg(qt_error_string());
cleanup();
setErrorAndEmit(QProcess::FailedToStart, errorString);
@@ -913,9 +894,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
{
static const DWORD errorElevationRequired = 740;
- if ((stdinChannel.type == Channel::Redirect && !openChannel(stdinChannel))
- || (stdoutChannel.type == Channel::Redirect && !openChannel(stdoutChannel))
- || (stderrChannel.type == Channel::Redirect && !openChannel(stderrChannel))) {
+ if (!openChannelsForDetached()) {
closeChannel(&stdinChannel);
closeChannel(&stdoutChannel);
closeChannel(&stderrChannel);