From b362279e86149529001d33bb2082944ab9cd0cb9 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 18 Sep 2021 18:11:09 +0300 Subject: [PATCH] Refactor QWindowsPipeWriter::writeCompleted() Change-Id: Id44215d6a96e7841330181c94cc54b6b677a153d Reviewed-by: Oswald Buddenhagen --- src/corelib/io/qwindowspipewriter.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/corelib/io/qwindowspipewriter.cpp b/src/corelib/io/qwindowspipewriter.cpp index 3024742d34..2d96a3d87d 100644 --- a/src/corelib/io/qwindowspipewriter.cpp +++ b/src/corelib/io/qwindowspipewriter.cpp @@ -250,15 +250,12 @@ void QWindowsPipeWriter::waitCallback(PTP_CALLBACK_INSTANCE instance, PVOID cont */ bool QWindowsPipeWriter::writeCompleted(DWORD errorCode, DWORD numberOfBytesWritten) { - if (errorCode == ERROR_SUCCESS) { + switch (errorCode) { + case ERROR_SUCCESS: bytesWrittenPending = true; pendingBytesWrittenValue += numberOfBytesWritten; writeBuffer.free(numberOfBytesWritten); return true; - } - - lastError = errorCode; - switch (errorCode) { case ERROR_PIPE_NOT_CONNECTED: // the other end has closed the pipe case ERROR_OPERATION_ABORTED: // the operation was canceled case ERROR_NO_DATA: // the pipe is being closed @@ -267,8 +264,10 @@ bool QWindowsPipeWriter::writeCompleted(DWORD errorCode, DWORD numberOfBytesWrit qErrnoWarning(errorCode, "QWindowsPipeWriter: write failed."); break; } + // The buffer is not cleared here, because the write progress // should appear on the main thread synchronously. + lastError = errorCode; return false; }