summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/heartrate-game/devicefinder.cpp
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-08-30 10:20:01 +0200
committerAlex Blasche <alexander.blasche@qt.io>2018-09-05 06:53:19 +0000
commita1e00ab195e879724efb0c03be8c06ddb6799fac (patch)
tree786861bfed6350d4ecdc7e1c72713fc02295c732 /examples/bluetooth/heartrate-game/devicefinder.cpp
parent68475e563d8a19f521278703a3e98c7664d6bbbc (diff)
Fix a few clazy/clang warnings in HeartRate Game example
Change-Id: I2a7b8c403ca466998ddcbd8496c31feb9856f0ad Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'examples/bluetooth/heartrate-game/devicefinder.cpp')
-rw-r--r--examples/bluetooth/heartrate-game/devicefinder.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/bluetooth/heartrate-game/devicefinder.cpp b/examples/bluetooth/heartrate-game/devicefinder.cpp
index 38f538e9..19ebee90 100644
--- a/examples/bluetooth/heartrate-game/devicefinder.cpp
+++ b/examples/bluetooth/heartrate-game/devicefinder.cpp
@@ -85,7 +85,7 @@ DeviceFinder::~DeviceFinder()
void DeviceFinder::startSearch()
{
clearMessages();
- m_deviceHandler->setDevice(0);
+ m_deviceHandler->setDevice(nullptr);
qDeleteAll(m_devices);
m_devices.clear();
@@ -135,7 +135,7 @@ void DeviceFinder::scanFinished()
m_devices.append(new DeviceInfo(QBluetoothDeviceInfo()));
#endif
- if (m_devices.size() == 0)
+ if (m_devices.isEmpty())
setError(tr("No Low Energy devices found."));
else
setInfo(tr("Scanning done."));
@@ -148,10 +148,11 @@ void DeviceFinder::connectToService(const QString &address)
{
m_deviceDiscoveryAgent->stop();
- DeviceInfo *currentDevice = 0;
- for (int i = 0; i < m_devices.size(); i++) {
- if (((DeviceInfo*)m_devices.at(i))->getAddress() == address ) {
- currentDevice = (DeviceInfo*)m_devices.at(i);
+ DeviceInfo *currentDevice = nullptr;
+ for (QObject *entry : qAsConst(m_devices)) {
+ auto device = qobject_cast<DeviceInfo *>(entry);
+ if (device && device->getAddress() == address ) {
+ currentDevice = device;
break;
}
}