summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@insta.fi>2022-04-06 15:19:11 +0300
committerJuha Vuolle <juha.vuolle@insta.fi>2022-04-12 11:11:42 +0300
commit2609a13d615d31f6f471395edc17e4bb932b08f1 (patch)
tree3b6a48fd445331bb062516dc30ed2ee3a1e79131 /tests
parenta9e99ee76989cc1cf91983563831f57c2134c6ba (diff)
downloadqtconnectivity-2609a13d615d31f6f471395edc17e4bb932b08f1.tar.gz
Fix bluetooth manual test application crash when no adapter
If there is no adapter available, the bluetoothtestdevice manual test application crashes as it accesses empty adapter list. Pick-to: 6.2 6.3 Change-Id: I2126cad73713976e453775b573518c041d369b52 Reviewed-by: Alex Blasche <alexander.blasche@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/bluetoothtestdevice/bluetoothtestdevice.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/bluetoothtestdevice/bluetoothtestdevice.cpp b/tests/bluetoothtestdevice/bluetoothtestdevice.cpp
index bb23deac..e6104952 100644
--- a/tests/bluetoothtestdevice/bluetoothtestdevice.cpp
+++ b/tests/bluetoothtestdevice/bluetoothtestdevice.cpp
@@ -280,6 +280,10 @@ int main(int argc, char *argv[])
#ifndef Q_OS_IOS
auto localAdapters = QBluetoothLocalDevice::allDevices();
+ if (localAdapters.isEmpty()) {
+ qWarning() << "Bluetoothtestdevice did not find a local adapter";
+ return EXIT_FAILURE;
+ }
QBluetoothLocalDevice adapter(localAdapters.back().address());
adapter.setHostMode(QBluetoothLocalDevice::HostDiscoverable);
#endif // Q_OS_IOS