From c74b2e2336662c9f0b5fb01b979b93ea0b99803d Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Tue, 15 Apr 2014 19:11:43 +0400 Subject: 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 Reviewed-by: Denis Shienkov --- src/serialport/qserialport_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index 6e6f7c6..e319863 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; } -- cgit v1.2.1