diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2014-10-10 21:51:12 +0400 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2014-11-27 21:31:42 +0100 |
commit | cb2ff89d4250fb089d5cf0fb4aeecdc35ae526ac (patch) | |
tree | 1f04228a2b9352c171faff557bc14f05ddded4d0 | |
parent | 11ed2f6216b89bf1ee52ce99c37822379f764d41 (diff) | |
download | qtserialport-cb2ff89d4250fb089d5cf0fb4aeecdc35ae526ac.tar.gz |
Prevent multiple calls of WaitCommEvent
Commit ac0422e8c9e74f2275129e3c7c69ef64299f07a9 introduced a regression
that QSP::startAsyncCommunication() was called twice when a limited read
buffer is used. In the second call the WaitCommEvent function returned the
ERROR_INVALID_PARAMETER error that lead to a stall of the read sequence.
QSP::startAsyncCommunication() should be called only when the read buffer
has enough space.
Tested on Windows 8 with the virtual com0com ports using Qt5.
Change-Id: Icd6cada7c3acfd4e689ac76ec304416b00f52b50
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
-rw-r--r-- | src/serialport/qserialport_win.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index bd9a9fb..c47f1e4 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -549,11 +549,12 @@ bool QSerialPortPrivate::_q_completeAsyncRead() readStarted = false; - // start async read for possible remainder into driver queue if ((bytesTransferred == ReadChunkSize) && (policy == QSerialPort::IgnorePolicy)) return startAsyncRead(); - else // driver queue is emplty, so startup wait comm event + else if (readBufferMaxSize == 0 || readBufferMaxSize > readBuffer.size()) return startAsyncCommunication(); + else + return true; } bool QSerialPortPrivate::_q_completeAsyncWrite() |