From 063cdb9870ab8a9b0f1a3741a001c06289f02af4 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Mon, 12 Apr 2021 16:31:51 +0300 Subject: 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 --- src/corelib/io/qwindowspipewriter.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'src/corelib/io/qwindowspipewriter.cpp') diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index 4b075549d0d..f2f4dce056e 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -39,7 +39,6 @@ ****************************************************************************/ #include "qwindowspipewriter_p.h" -#include #include #include @@ -56,8 +55,7 @@ QWindowsPipeWriter::QWindowsPipeWriter(HANDLE pipeWriteEnd, QObject *parent) stopped(true), writeSequenceStarted(false), bytesWrittenPending(false), - winEventActPosted(false), - inBytesWritten(false) + winEventActPosted(false) { ZeroMemory(&overlapped, sizeof(OVERLAPPED)); overlapped.hEvent = eventHandle; @@ -290,12 +288,7 @@ bool QWindowsPipeWriter::consumePendingAndEmit(bool allowWinActPosting) if (stopped) return false; - emit canWrite(); - if (!inBytesWritten) { - QScopedValueRollback guard(inBytesWritten, true); - emit bytesWritten(numberOfBytesWritten); - } - + emit bytesWritten(numberOfBytesWritten); return true; } @@ -317,8 +310,7 @@ bool QWindowsPipeWriter::waitForNotification(const QDeadlineTimer &deadline) /*! Waits for the completion of the asynchronous write operation. - Returns \c true, if we've emitted the bytesWritten signal (non-recursive case) - or bytesWritten will be emitted by the event loop (recursive case). + Returns \c true, if we've emitted the bytesWritten signal. */ bool QWindowsPipeWriter::waitForWrite(int msecs) { -- cgit v1.2.3