From cb2ff89d4250fb089d5cf0fb4aeecdc35ae526ac Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Fri, 10 Oct 2014 21:51:12 +0400 Subject: 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 Reviewed-by: Sergey Belyashov --- src/serialport/qserialport_win.cpp | 5 +++-- 1 file 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() -- cgit v1.2.1