summaryrefslogtreecommitdiffstats
path: root/qtserialbluetooth.cpp
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2015-09-22 23:33:15 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-22 19:36:54 -0700
commit113ab59d812a6800fb2d47201b344de81ea576a6 (patch)
treecd50767062664b211f650fee2ab6d89f2ec1e4be /qtserialbluetooth.cpp
parent8417e84e8295d478f77512bcac455cd2ce925726 (diff)
downloadsubsurface-113ab59d812a6800fb2d47201b344de81ea576a6.tar.gz
qtbluetooth: Break read/write loops on bad state
This introduces a state check to only continue to try to read/write from the bluetooth device while its in a sane state. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qtserialbluetooth.cpp')
-rw-r--r--qtserialbluetooth.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/qtserialbluetooth.cpp b/qtserialbluetooth.cpp
index ee8b2b793..6f93d8cab 100644
--- a/qtserialbluetooth.cpp
+++ b/qtserialbluetooth.cpp
@@ -234,7 +234,7 @@ static int qt_serial_read(serial_t *device, void* data, unsigned int size)
unsigned int nbytes = 0;
int rc;
- while(nbytes < size)
+ while(nbytes < size && device->socket->state() == QBluetoothSocket::ConnectedState)
{
device->socket->waitForReadyRead(device->timeout);
@@ -293,7 +293,7 @@ static int qt_serial_write(serial_t *device, const void* data, unsigned int size
unsigned int nbytes = 0;
int rc;
- while(nbytes < size)
+ while(nbytes < size && device->socket->state() == QBluetoothSocket::ConnectedState)
{
device->socket->waitForBytesWritten(device->timeout);