inline QWindowsPipeReader::completeAsyncRead

There's exactly one caller for this private method, and future code
will be a bit simpler after moving the code to the calling site.

Change-Id: Ibc65f91c770f9f29b317ceddb39a67d52106da33
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
Joerg Bornemann 2015-04-16 16:18:45 +02:00
parent bb8f621480
commit a7f1c97d60
2 changed files with 23 additions and 32 deletions

View File

@ -165,11 +165,33 @@ void QWindowsPipeReader::notified(quint32 numberOfBytesRead, quint32 errorCode,
{
if (&overlapped != notifiedOverlapped)
return;
if (!completeAsyncRead(numberOfBytesRead, errorCode)) {
switch (errorCode) {
case ERROR_SUCCESS:
break;
case ERROR_MORE_DATA:
// This is not an error. We're connected to a message mode
// pipe and the message didn't fit into the pipe's system
// buffer. We will read the remaining data in the next call.
break;
case ERROR_BROKEN_PIPE:
case ERROR_PIPE_NOT_CONNECTED:
pipeBroken = true;
break;
default:
emit winError(errorCode, QLatin1String("QWindowsPipeReader::completeAsyncRead"));
pipeBroken = true;
break;
}
readSequenceStarted = false;
if (pipeBroken) {
emit pipeClosed();
return;
}
actualReadBufferSize += numberOfBytesRead;
readBuffer.truncate(actualReadBufferSize);
startAsyncRead();
readyReadEmitted = true;
emit readyRead();
@ -232,36 +254,6 @@ void QWindowsPipeReader::startAsyncRead()
}
}
/*!
\internal
Sets the correct size of the read buffer after a read operation.
Returns \c false, if an error occurred or the connection dropped.
*/
bool QWindowsPipeReader::completeAsyncRead(DWORD bytesRead, DWORD errorCode)
{
readSequenceStarted = false;
switch (errorCode) {
case ERROR_SUCCESS:
break;
case ERROR_MORE_DATA:
// This is not an error. We're connected to a message mode
// pipe and the message didn't fit into the pipe's system
// buffer. We will read the remaining data in the next call.
break;
case ERROR_BROKEN_PIPE:
case ERROR_PIPE_NOT_CONNECTED:
return false;
default:
emit winError(errorCode, QLatin1String("QWindowsPipeReader::completeAsyncRead"));
return false;
}
actualReadBufferSize += bytesRead;
readBuffer.truncate(actualReadBufferSize);
return true;
}
/*!
\internal
Returns the number of available bytes in the pipe.

View File

@ -88,7 +88,6 @@ private Q_SLOTS:
void notified(quint32 numberOfBytesRead, quint32 errorCode, OVERLAPPED *notifiedOverlapped);
private:
bool completeAsyncRead(DWORD bytesRead, DWORD errorCode);
DWORD checkPipeState();
private: