summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2017-06-29 11:01:08 +0200
committerAlex Blasche <alexander.blasche@qt.io>2017-06-29 09:57:24 +0000
commit31990acd549f3f811b60caefa6371ec8fc09bb4b (patch)
treea0c8ce25f302998f07f5e7d3f9274ee6e6088e86
parent2f596f9b80084df8897215d8436ffbbdc962198a (diff)
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 <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp2
-rw-r--r--src/bluetooth/qbluetoothsocket_android.cpp5
-rw-r--r--src/bluetooth/qbluetoothsocket_bluez.cpp5
-rw-r--r--src/bluetooth/qbluetoothsocket_p.cpp5
-rw-r--r--src/bluetooth/qbluetoothsocket_p.h1
-rw-r--r--src/bluetooth/qbluetoothsocket_winrt.cpp5
6 files changed, 22 insertions, 1 deletions
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();