diff options
| author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-04-12 16:31:51 +0300 |
|---|---|---|
| committer | Oswald Buddenhagen <oswald.buddenhagen@gmx.de> | 2021-04-15 19:00:42 +0000 |
| commit | 063cdb9870ab8a9b0f1a3741a001c06289f02af4 (patch) | |
| tree | 3dcba5254f8ae4d2f250ffadaec0f93f865048e7 /src/corelib/io/qwindowspipereader.cpp | |
| parent | 92d351089bf7e285c9800342ff72205c04984f6c (diff) | |
QWindowsPipe{Reader|Writer}: restructure signals
For QProcess, there is no point in suppressing recursive
QWPR::readyRead() emission, as the former manages this logic itself. On
top of that, the non-recursive nature of QWPR::readyRead() indirectly
disallowed reading from the channels inside
QProcess::waitForReadyRead(), if that is called from a slot connected
to QProcess::readyRead().
QWPW had two signals, one allowing recursion and one not.
This commit allows recursion of QWPR::readyRead() and
QWPW::bytesWritten(), and moves recursion suppression to the higher-
level classes. This makes the code more uniform and efficient, at the
cost of a few duplicated lines.
Change-Id: Ib20017fff4d92403d0bf2335f1622de4aa1ddcef
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io/qwindowspipereader.cpp')
| -rw-r--r-- | src/corelib/io/qwindowspipereader.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/corelib/io/qwindowspipereader.cpp b/src/corelib/io/qwindowspipereader.cpp index b8ea89b8e3c..9030c3aaa11 100644 --- a/src/corelib/io/qwindowspipereader.cpp +++ b/src/corelib/io/qwindowspipereader.cpp @@ -39,7 +39,6 @@ ****************************************************************************/ #include "qwindowspipereader_p.h" -#include <qscopedvaluerollback.h> #include <qcoreapplication.h> #include <QMutexLocker> @@ -61,8 +60,7 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent) readSequenceStarted(false), pipeBroken(false), readyReadPending(false), - winEventActPosted(false), - inReadyRead(false) + winEventActPosted(false) { ZeroMemory(&overlapped, sizeof(OVERLAPPED)); overlapped.hEvent = eventHandle; @@ -424,10 +422,8 @@ bool QWindowsPipeReader::consumePendingAndEmit(bool allowWinActPosting) if (state != Running) return false; - if (emitReadyRead && !inReadyRead) { - QScopedValueRollback<bool> guard(inReadyRead, true); + if (emitReadyRead) emit readyRead(); - } if (emitPipeClosed) { if (dwError != ERROR_BROKEN_PIPE && dwError != ERROR_PIPE_NOT_CONNECTED) emit winError(dwError, QLatin1String("QWindowsPipeReader::consumePendingAndEmit")); @@ -484,8 +480,7 @@ bool QWindowsPipeReader::waitForNotification(const QDeadlineTimer &deadline) /*! Waits for the completion of the asynchronous read operation. - Returns \c true, if we've emitted the readyRead signal (non-recursive case) - or readyRead will be emitted by the event loop (recursive case). + Returns \c true, if we've emitted the readyRead signal. */ bool QWindowsPipeReader::waitForReadyRead(int msecs) { |
