remove emitReadyReadTimer from QWindowsPipeReader
The zero timeout singleshot timer emitReadyReadTimer was used to emit the readyRead signal via the event loop in case of a synchronous read. In that particular case, ReadFile would return successfully, and the notified slot would not be called. Now, that we use an I/O completion port, the notified slot is always called, even in the synchronous case. The emitReadyReadTimer is not needed anymore. This is also supported by the fact that the timer is immediately stopped in notified() after it was started in completeAsyncRead(). Change-Id: I93bcde5f067bf89a1d49005a3fddda4c8c8c95fc Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
5fc52ba6e2
commit
bb8f621480
@ -36,7 +36,6 @@
|
||||
#include <qdebug.h>
|
||||
#include <qelapsedtimer.h>
|
||||
#include <qeventloop.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -46,12 +45,9 @@ QWindowsPipeReader::QWindowsPipeReader(QObject *parent)
|
||||
readBufferMaxSize(0),
|
||||
actualReadBufferSize(0),
|
||||
readSequenceStarted(false),
|
||||
emitReadyReadTimer(new QTimer(this)),
|
||||
pipeBroken(false),
|
||||
readyReadEmitted(false)
|
||||
{
|
||||
emitReadyReadTimer->setSingleShot(true);
|
||||
connect(emitReadyReadTimer, SIGNAL(timeout()), SIGNAL(readyRead()));
|
||||
dataReadNotifier = new QWinOverlappedIoNotifier(this);
|
||||
connect(dataReadNotifier, &QWinOverlappedIoNotifier::notified, this, &QWindowsPipeReader::notified);
|
||||
}
|
||||
@ -146,8 +142,6 @@ qint64 QWindowsPipeReader::read(char *data, qint64 maxlen)
|
||||
}
|
||||
|
||||
if (!pipeBroken) {
|
||||
if (!actualReadBufferSize)
|
||||
emitReadyReadTimer->stop();
|
||||
if (!readSequenceStarted)
|
||||
startAsyncRead();
|
||||
if (readSoFar == 0)
|
||||
@ -177,7 +171,6 @@ void QWindowsPipeReader::notified(quint32 numberOfBytesRead, quint32 errorCode,
|
||||
return;
|
||||
}
|
||||
startAsyncRead();
|
||||
emitReadyReadTimer->stop();
|
||||
readyReadEmitted = true;
|
||||
emit readyRead();
|
||||
}
|
||||
@ -266,8 +259,6 @@ bool QWindowsPipeReader::completeAsyncRead(DWORD bytesRead, DWORD errorCode)
|
||||
|
||||
actualReadBufferSize += bytesRead;
|
||||
readBuffer.truncate(actualReadBufferSize);
|
||||
if (!emitReadyReadTimer->isActive())
|
||||
emitReadyReadTimer->start();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,6 @@
|
||||
|
||||
#include <qbytearray.h>
|
||||
#include <qobject.h>
|
||||
#include <qtimer.h>
|
||||
#include <private/qringbuffer_p.h>
|
||||
|
||||
#include <qt_windows.h>
|
||||
@ -100,7 +99,6 @@ private:
|
||||
QRingBuffer readBuffer;
|
||||
int actualReadBufferSize;
|
||||
bool readSequenceStarted;
|
||||
QTimer *emitReadyReadTimer;
|
||||
bool pipeBroken;
|
||||
bool readyReadEmitted;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user