summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBogDan Vatra <bogdan@kdab.com>2016-12-07 17:25:36 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2016-12-08 07:07:59 +0000
commit64aefd7eec6250a6e443dc236ea08a123045de91 (patch)
treebf355a10a3e5da5c0a4c5e255f11a4e9c6551307
parent5c25bb79da0d37c0cf67ba7feb88b04ce1fd7377 (diff)
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 <alexander.blasche@qt.io>
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_android.cpp4
1 files changed, 4 insertions, 0 deletions
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<QBluetoothHostInfo> 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;