From 31990acd549f3f811b60caefa6371ec8fc09bb4b Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 29 Jun 2017 11:01:08 +0200 Subject: Add indirection for QBluetoothSocket::bytesToWrite() Not all platforms use txbuffer for writes. Fortunately those platforms who do not use it do not use any buffering at all. Hence bytesToWrite() returned the correct value as txbuffer always had size zero. Therefore this patch is effectively a NOP. Nevertheless this patch encourages the right implementation across the platform. This does not affect macOS as it has a separate implementation for QBluetoothSocket::bytesToWrite(). Task-number: QTBUG-58190 Change-Id: Ic05f4358b079f612ee7e0e4dbb7fb9aa78fd6556 Reviewed-by: Qt CI Bot Reviewed-by: Oliver Wolff --- src/bluetooth/qbluetoothsocket.cpp | 2 +- src/bluetooth/qbluetoothsocket_android.cpp | 5 +++++ src/bluetooth/qbluetoothsocket_bluez.cpp | 5 +++++ src/bluetooth/qbluetoothsocket_p.cpp | 5 +++++ src/bluetooth/qbluetoothsocket_p.h | 1 + src/bluetooth/qbluetoothsocket_winrt.cpp | 5 +++++ 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp index 57dd3aa0..2f38ed04 100644 --- a/src/bluetooth/qbluetoothsocket.cpp +++ b/src/bluetooth/qbluetoothsocket.cpp @@ -300,7 +300,7 @@ qint64 QBluetoothSocket::bytesAvailable() const qint64 QBluetoothSocket::bytesToWrite() const { Q_D(const QBluetoothSocket); - return d->txBuffer.size(); + return d->bytesToWrite(); } /*! diff --git a/src/bluetooth/qbluetoothsocket_android.cpp b/src/bluetooth/qbluetoothsocket_android.cpp index c2fc96f2..6a92f29a 100644 --- a/src/bluetooth/qbluetoothsocket_android.cpp +++ b/src/bluetooth/qbluetoothsocket_android.cpp @@ -879,6 +879,11 @@ qint64 QBluetoothSocketPrivate::bytesAvailable() const return 0; } +qint64 QBluetoothSocketPrivate::bytesToWrite() const +{ + return 0; // nothing because always unbuffered +} + bool QBluetoothSocketPrivate::canReadLine() const { // We cannot access buffer directly as it is part of different thread diff --git a/src/bluetooth/qbluetoothsocket_bluez.cpp b/src/bluetooth/qbluetoothsocket_bluez.cpp index dca1bc3b..6aef811a 100644 --- a/src/bluetooth/qbluetoothsocket_bluez.cpp +++ b/src/bluetooth/qbluetoothsocket_bluez.cpp @@ -592,6 +592,11 @@ qint64 QBluetoothSocketPrivate::bytesAvailable() const return buffer.size(); } +qint64 QBluetoothSocketPrivate::bytesToWrite() const +{ + return txBuffer.size(); +} + bool QBluetoothSocketPrivate::canReadLine() const { return buffer.canReadLine(); diff --git a/src/bluetooth/qbluetoothsocket_p.cpp b/src/bluetooth/qbluetoothsocket_p.cpp index dc14e97b..39d483d6 100644 --- a/src/bluetooth/qbluetoothsocket_p.cpp +++ b/src/bluetooth/qbluetoothsocket_p.cpp @@ -163,4 +163,9 @@ bool QBluetoothSocketPrivate::canReadLine() const return false; } +qint64 QBluetoothSocketPrivate::bytesToWrite() const +{ + return 0; +} + QT_END_NAMESPACE diff --git a/src/bluetooth/qbluetoothsocket_p.h b/src/bluetooth/qbluetoothsocket_p.h index cfa342bb..9aabf660 100644 --- a/src/bluetooth/qbluetoothsocket_p.h +++ b/src/bluetooth/qbluetoothsocket_p.h @@ -167,6 +167,7 @@ public: qint64 bytesAvailable() const; bool canReadLine() const; + qint64 bytesToWrite() const; public: QPrivateLinearBuffer buffer; diff --git a/src/bluetooth/qbluetoothsocket_winrt.cpp b/src/bluetooth/qbluetoothsocket_winrt.cpp index a56e10fa..4a9d1b93 100644 --- a/src/bluetooth/qbluetoothsocket_winrt.cpp +++ b/src/bluetooth/qbluetoothsocket_winrt.cpp @@ -569,6 +569,11 @@ qint64 QBluetoothSocketPrivate::bytesAvailable() const return buffer.size(); } +qint64 QBluetoothSocketPrivate::bytesToWrite() const +{ + return 0; // nothing because always unbuffered +} + bool QBluetoothSocketPrivate::canReadLine() const { return buffer.canReadLine(); -- cgit v1.2.3