From e5dfb098638628b0215e11791bce372a656af390 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Fri, 21 Apr 2017 19:31:58 +0300 Subject: Fix bytesToWrite() We should not add the size of the internal write buffer here because QIODevice::bytesToWrite() already checks it. Also, take into account the size of 'writeChunkBuffer' on Windows. Change-Id: I87dfcb4dd1cd9d2bbb6f82a084d79fb4db9323d8 Reviewed-by: Thiago Macieira --- src/serialport/qserialport.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index 8140deb..5534bb8 100644 --- a/src/serialport/qserialport.cpp +++ b/src/serialport/qserialport.cpp @@ -1283,8 +1283,11 @@ qint64 QSerialPort::bytesAvailable() const */ qint64 QSerialPort::bytesToWrite() const { - Q_D(const QSerialPort); - return QIODevice::bytesToWrite() + d->writeBuffer.size(); + qint64 pendingBytes = QIODevice::bytesToWrite(); +#if defined(Q_OS_WIN32) + pendingBytes += d_func()->writeChunkBuffer.size(); +#endif + return pendingBytes; } /*! -- cgit v1.2.1