From 6e07edb260bb8c0ad67fe2e618125bd03a074b99 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Thu, 26 Nov 2020 17:37:13 +0200 Subject: [PATCH] QProcess/Unix: remove redundant checks in waitForReadyRead() QProcessPrivate::tryReadFromChannel() returns 'true' only if we emitted readyRead() signal on the current read channel. Thus, these additional checks are unnecessary. Change-Id: Id98620cd08ee8808f60539c009986b869e517ef0 Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qprocess_unix.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index f791ee94eea..9e5b26b3d6d 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -749,17 +749,14 @@ bool QProcessPrivate::waitForReadyRead(int msecs) return false; } + // This calls QProcessPrivate::tryReadFromChannel(), which returns true + // if we emitted readyRead() signal on the current read channel. bool readyReadEmitted = false; - if (qt_pollfd_check(poller.stdoutPipe(), POLLIN)) { - bool canRead = _q_canReadStandardOutput(); - if (currentReadChannel == QProcess::StandardOutput && canRead) - readyReadEmitted = true; - } - if (qt_pollfd_check(poller.stderrPipe(), POLLIN)) { - bool canRead = _q_canReadStandardError(); - if (currentReadChannel == QProcess::StandardError && canRead) - readyReadEmitted = true; - } + if (qt_pollfd_check(poller.stdoutPipe(), POLLIN) && _q_canReadStandardOutput()) + readyReadEmitted = true; + if (qt_pollfd_check(poller.stderrPipe(), POLLIN) && _q_canReadStandardError()) + readyReadEmitted = true; + if (readyReadEmitted) return true;