From 113ab59d812a6800fb2d47201b344de81ea576a6 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Tue, 22 Sep 2015 23:33:15 +0200 Subject: [PATCH] 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 Signed-off-by: Dirk Hohndel --- qtserialbluetooth.cpp | 4 ++-- 1 file 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);