diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2014-04-15 19:11:43 +0400 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-05-15 14:48:10 +0200 |
commit | c74b2e2336662c9f0b5fb01b979b93ea0b99803d (patch) | |
tree | b870128364fd6c66200464777a613c00c6ed22a0 /src | |
parent | b749c9dc00f22ecfcf4be6684b3596b20f7ae0c4 (diff) |
Fix the waitForBytesWritten() behavior on Windows
The slot _q_completeAsyncWrite(), which is used inside of
waitForBytesWritten(), returns void. To define the status
of write completion method was used the last error code,
where any value are not equal to NoError was interpreted
as an error.
But this behavior was incorrect because the error code
number could be set by any other previous I/O operation
and remained not cleared. Therefore waitForBytesWritten()
always returns false.
A good solution it is to compare size of the writeBuffer
after completion of each write operation with zero, because
the buffer should be empty.
Tested on Windows 8 with the on-board and the USB serial
ports and the cwritersync example using Qt5.
Task-number: QTBUG-36758
Change-Id: I2cf6f9e08056d2e237211b19cff59990aac53bc1
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/serialport/qserialport_win.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index 6e6f7c6d..e3198637 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -461,7 +461,7 @@ bool QSerialPortPrivate::waitForBytesWritten(int msecs) _q_completeAsyncRead(); } else if (triggeredEvent == writeCompletionOverlapped.hEvent) { _q_completeAsyncWrite(); - return error == QSerialPort::NoError; + return writeBuffer.isEmpty(); } else { return false; } |