mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
8417e84e82
commit
113ab59d81
1 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue