From 64aefd7eec6250a6e443dc236ea08a123045de91 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Wed, 7 Dec 2016 17:25:36 +0200 Subject: Android: Fixed crash getDefaultAdapter might fail and it will throw an exception if the bt is not turned on, we must clear all pending exceptions otherwise next java call will crash the application. Task-number: QTBUG-57489 Change-Id: I191247528065acb3cdc4f6c0d36371ebf9f2e2c8 Reviewed-by: Alex Blasche --- src/bluetooth/qbluetoothlocaldevice_android.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bluetooth/qbluetoothlocaldevice_android.cpp b/src/bluetooth/qbluetoothlocaldevice_android.cpp index 72162fd4..9166c9a2 100644 --- a/src/bluetooth/qbluetoothlocaldevice_android.cpp +++ b/src/bluetooth/qbluetoothlocaldevice_android.cpp @@ -325,6 +325,10 @@ QList QBluetoothLocalDevice::allDevices() jobject btAdapterObject = env->CallStaticObjectMethod(btAdapterClass, getDefaultAdapterID); if (btAdapterObject == NULL) { + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + } qCWarning(QT_BT_ANDROID) << "Device does not support Bluetooth"; env->DeleteLocalRef(btAdapterClass); return localDevices; -- cgit v1.2.3