summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2014-05-27 19:34:06 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-03 14:08:41 +0200
commitd598a00e823d8509fc67fc2452dcaf2939092804 (patch)
tree7c51ffa04a408da27e453c6527838c641d9790a1 /src
parent2271479ff5d58b792af2c3823afe0f88fbf047ea (diff)
Fix waitForReadyRead() on windows
The commit 2360c401ae2012ed1b5a2b470a088cbbdb0d7f27 introduced an regression into waitForReadyRead(). Before this commit each read transaction was started again until the zero number of bytes will returns from FIFO. When FIFO is empty, all data has been read, and only then the waitForReadyRead() return true. I.e. condition "qint64(readBuffer.size()) != currentReadBufferSize" does not mean that reading is finished. But after that commit this condition is incorrect, because now each read operation started once and can not return zero bytes (in case the number of read bytes less than ReadChunkSize). Thus it led to returning of TimeoutError error. Now, this issue has been fixed. Also is added the set of auto-tests to testing of the waitForReadyRead() method. Tested on Windows 7/8 using Qt5 and then Qt4. Task-number: QTBUG-39314 Change-Id: I8abbf986c2a1cc77af634ddbc1747fb46f416a39 Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/serialport/qserialport_win.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index 5411d17c..111a8ce0 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -403,10 +403,15 @@ bool QSerialPortPrivate::waitForReadyRead(int msecs)
_q_completeAsyncCommunication();
} else if (triggeredEvent == readCompletionOverlapped.hEvent) {
_q_completeAsyncRead();
- if (qint64(readBuffer.size()) != currentReadBufferSize)
+ const qint64 readBytesForOneReadOperation = qint64(readBuffer.size()) - currentReadBufferSize;
+ if (readBytesForOneReadOperation == ReadChunkSize) {
currentReadBufferSize = readBuffer.size();
- else if (initialReadBufferSize != currentReadBufferSize)
+ } else if (readBytesForOneReadOperation == 0) {
+ if (initialReadBufferSize != currentReadBufferSize)
+ return true;
+ } else {
return true;
+ }
} else if (triggeredEvent == writeCompletionOverlapped.hEvent) {
_q_completeAsyncWrite();
} else {