diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2014-07-26 01:31:28 +0400 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2014-07-30 10:32:40 +0200 |
commit | 26504a5fe1c13af3b84b60eb2a5eb754c80d3c22 (patch) | |
tree | 6963b6caea19d0229a7996809430e643146e8933 /src | |
parent | 76f293bfb0fd7bab391f96ac822eacc40e4c5176 (diff) | |
download | qtserialport-26504a5fe1c13af3b84b60eb2a5eb754c80d3c22.tar.gz |
Fix events handling in waitForBytesWritten() method on Windows
In case of communication event is triggered in the
waitForBytesWritten() method then necessary to process it with
the _q_completeAsyncCommunication() method, but not with the
_q_completeAsyncRead() method.
Otherwise it leads to false filling of the readBuffer with the
data that were read earlier (or with garbage) which remained in
readChunkBuffer.
The synchronous loopback autotest reproduces a bug without of
this patch.
Tested on Windows 7/8 with the on-board and USB serial ports,
using Qt5.
Task-number: QTBUG-40344
Change-Id: I679109b60f4058c4c6f7e5f02c1f70ba6039d8d8
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/serialport/qserialport_win.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index 3432fc9..a6e1df7 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -449,8 +449,10 @@ bool QSerialPortPrivate::waitForBytesWritten(int msecs) return false; } - if (triggeredEvent == communicationOverlapped.hEvent - || triggeredEvent == readCompletionOverlapped.hEvent) { + if (triggeredEvent == communicationOverlapped.hEvent) { + if (!_q_completeAsyncCommunication()) + return false; + } else if (triggeredEvent == readCompletionOverlapped.hEvent) { if (!_q_completeAsyncRead()) return false; } else if (triggeredEvent == writeCompletionOverlapped.hEvent) { |