From b827a21be00f5161b4b42ddaf3f8a46477d39054 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 29 Jun 2017 11:15:15 +0200 Subject: Android: Do not emit QBluetoothSocket::bytesWritten() if write() failed QBluetoothSocket::write() emits the bytesWritten(int) signal when the write was successful. java.io.OutputStream.write() returns an exception when it fails. We should not emit bytesWritten() if such an exception occurred. Change-Id: I76e7a85188102e8227d586450c3e733c046e9957 Reviewed-by: Christian Stromme Reviewed-by: Oliver Wolff --- src/bluetooth/qbluetoothsocket_android.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bluetooth/qbluetoothsocket_android.cpp b/src/bluetooth/qbluetoothsocket_android.cpp index 6a92f29a..d0b901ae 100644 --- a/src/bluetooth/qbluetoothsocket_android.cpp +++ b/src/bluetooth/qbluetoothsocket_android.cpp @@ -722,7 +722,6 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize) env->SetByteArrayRegion(nativeData, 0, (qint32)maxSize, reinterpret_cast(data)); outputStream.callMethod("write", "([BII)V", nativeData, 0, (qint32)maxSize); env->DeleteLocalRef(nativeData); - emit q->bytesWritten(maxSize); if (env->ExceptionCheck()) { qCWarning(QT_BT_ANDROID) << "Error while writing"; @@ -733,6 +732,7 @@ qint64 QBluetoothSocketPrivate::writeData(const char *data, qint64 maxSize) return -1; } + emit q->bytesWritten(maxSize); return maxSize; } -- cgit v1.2.3