summaryrefslogtreecommitdiffstats
path: root/src/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'src/bluetooth')
-rw-r--r--src/bluetooth/bluetooth.pro2
-rw-r--r--src/bluetooth/bluez/bluez5_helper.cpp8
-rw-r--r--src/bluetooth/osx/osxbtobexsession.mm4
-rw-r--r--src/bluetooth/osx/osxbtsdpinquiry.mm2
-rw-r--r--src/bluetooth/osx/osxbtservicerecord.mm6
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent.cpp2
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp4
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm2
-rw-r--r--src/bluetooth/qbluetoothlocaldevice_bluez.cpp11
-rw-r--r--src/bluetooth/qbluetoothserver_android.cpp2
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp2
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_android.cpp2
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp17
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_osx.mm2
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp8
-rw-r--r--src/bluetooth/qbluetoothserviceinfo.cpp11
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_android.cpp2
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_bluez.cpp4
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_osx.mm11
-rw-r--r--src/bluetooth/qbluetoothserviceinfo_winrt.cpp5
-rw-r--r--src/bluetooth/qleadvertiser_bluez.cpp7
-rw-r--r--src/bluetooth/qlowenergycharacteristic.cpp2
-rw-r--r--src/bluetooth/qlowenergycharacteristicdata.cpp2
-rw-r--r--src/bluetooth/qlowenergycontroller_android.cpp4
-rw-r--r--src/bluetooth/qlowenergycontroller_bluez.cpp33
-rw-r--r--src/bluetooth/qlowenergycontroller_osx.mm8
-rw-r--r--src/bluetooth/qlowenergycontroller_winrt.cpp6
-rw-r--r--src/bluetooth/qlowenergycontrollerbase.cpp13
-rw-r--r--src/bluetooth/qlowenergyservice.cpp2
-rw-r--r--src/bluetooth/qlowenergyservice_osx.mm2
-rw-r--r--src/bluetooth/qlowenergyservicedata.cpp2
31 files changed, 110 insertions, 78 deletions
diff --git a/src/bluetooth/bluetooth.pro b/src/bluetooth/bluetooth.pro
index 72208a87..193ed217 100644
--- a/src/bluetooth/bluetooth.pro
+++ b/src/bluetooth/bluetooth.pro
@@ -1,6 +1,6 @@
TARGET = QtBluetooth
QT = core core-private
-
+DEFINES += QT_NO_FOREACH
QMAKE_DOCS = $$PWD/doc/qtbluetooth.qdocconf
OTHER_FILES += doc/src/*.qdoc # show .qdoc files in Qt Creator
diff --git a/src/bluetooth/bluez/bluez5_helper.cpp b/src/bluetooth/bluez/bluez5_helper.cpp
index f798088e..2beb533c 100644
--- a/src/bluetooth/bluez/bluez5_helper.cpp
+++ b/src/bluetooth/bluez/bluez5_helper.cpp
@@ -331,7 +331,8 @@ QtBluezDiscoveryManager::~QtBluezDiscoveryManager()
{
qCDebug(QT_BT_BLUEZ) << "Destroying QtBluezDiscoveryManager";
- foreach (const QString &adapterPath, d->references.keys()) {
+ const QList<QString> adapterPaths = d->references.keys();
+ for (const QString &adapterPath : adapterPaths) {
AdapterData *data = d->references.take(adapterPath);
delete data->propteryListener;
@@ -416,7 +417,8 @@ void QtBluezDiscoveryManager::unregisterDiscoveryInterest(const QString &adapter
// if (d->references.isEmpty()) {
// qCDebug(QT_BT_BLUEZ) << "No running registration";
// } else {
-// foreach (const QString &path, d->references.keys()) {
+// const QList<QString> paths = d->references.keys();
+// for (const QString &path : paths) {
// qCDebug(QT_BT_BLUEZ) << path << "->" << d->references[path]->reference;
// }
// }
@@ -536,7 +538,7 @@ QString findAdapterForAddress(const QBluetoothAddress &wantedAddress, bool *ok =
if (wantedAddress.isNull())
return localAdapters.front().first; // -> return first found adapter
- foreach (const AddressForPathType &pair, localAdapters) {
+ for (const AddressForPathType &pair : qAsConst(localAdapters)) {
if (pair.second == wantedAddress)
return pair.first; // -> found local adapter with wanted address
}
diff --git a/src/bluetooth/osx/osxbtobexsession.mm b/src/bluetooth/osx/osxbtobexsession.mm
index e228d6db..9fbc2c12 100644
--- a/src/bluetooth/osx/osxbtobexsession.mm
+++ b/src/bluetooth/osx/osxbtobexsession.mm
@@ -537,14 +537,14 @@ QT_USE_NAMESPACE
const OBEXConnectCommandResponseData *const response = &event->u.connectCommandResponseData;
if (response->headerDataPtr && response->headerDataLength >= 2) {
// 2 == 1 byte headerID + at least 1 byte headerValue ...
- QList<OBEXHeader> headers(qt_bluetooth_headers(static_cast<const uint8_t *>(response->headerDataPtr),
+ const QList<OBEXHeader> headers(qt_bluetooth_headers(static_cast<const uint8_t *>(response->headerDataPtr),
response->headerDataLength));
// ConnectionID is used when multiplexing OBEX connections
// to identify which particular connection this object is
// being sent on. When used, this _must_ be the first
// header sent.
- foreach (const OBEXHeader &header, headers) {
+ for (const OBEXHeader &header : headers) {
if (header.headerID == kOBEXHeaderIDConnectionID) {
connectionID = header.value.value<quint32>();
connectionIDFound = true;
diff --git a/src/bluetooth/osx/osxbtsdpinquiry.mm b/src/bluetooth/osx/osxbtsdpinquiry.mm
index a0bfdeef..6df2d16e 100644
--- a/src/bluetooth/osx/osxbtsdpinquiry.mm
+++ b/src/bluetooth/osx/osxbtsdpinquiry.mm
@@ -188,7 +188,7 @@ using namespace OSXBluetooth;
return kIOReturnError;
}
- foreach (const QBluetoothUuid &qUuid, qtFilters) {
+ for (const QBluetoothUuid &qUuid : qtFilters) {
ObjCStrongReference<IOBluetoothSDPUUID> uuid(iobluetooth_uuid(qUuid));
if (uuid)
[array addObject:uuid];
diff --git a/src/bluetooth/osx/osxbtservicerecord.mm b/src/bluetooth/osx/osxbtservicerecord.mm
index d12169bb..23d55d13 100644
--- a/src/bluetooth/osx/osxbtservicerecord.mm
+++ b/src/bluetooth/osx/osxbtservicerecord.mm
@@ -386,7 +386,7 @@ bool add_sequence_attribute(const QVariant &var, AttributeId key, NSMutableArray
return false;
const Sequence sequence(var.value<Sequence>());
- foreach (const QVariant &var, sequence) {
+ for (const QVariant &var : sequence) {
if (var.canConvert<Sequence>()) {
NSMutableArray *const nested = [NSMutableArray array];
add_sequence_attribute(var, key, nested);
@@ -411,7 +411,7 @@ bool add_sequence_attribute(const QBluetoothServiceInfo &serviceInfo, AttributeI
NSMutableArray *const list = [NSMutableArray array];
const Sequence sequence(var.value<Sequence>());
- foreach (const QVariant &element, sequence) {
+ for (const QVariant &element : sequence) {
if (!add_sequence_attribute(element, key, list))
add_attribute(element, key, list);
}
@@ -433,7 +433,7 @@ Dictionary iobluetooth_service_dictionary(const QBluetoothServiceInfo &serviceIn
dict.reset([[NSMutableDictionary alloc] init]);
- foreach (quint16 key, attributeIds) {
+ for (quint16 key : attributeIds) {
if (key == QSInfo::ProtocolDescriptorList) // We handle it in a special way.
continue;
// TODO: check if non-sequence QVariant still must be
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
index 5f142f1a..a9e35960 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
@@ -210,7 +210,7 @@ QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(
{
if (!deviceAdapter.isNull()) {
const QList<QBluetoothHostInfo> localDevices = QBluetoothLocalDevice::allDevices();
- foreach (const QBluetoothHostInfo &hostInfo, localDevices) {
+ for (const QBluetoothHostInfo &hostInfo : localDevices) {
if (hostInfo.address() == deviceAdapter)
return;
}
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
index 3cc3354a..3d09a4df 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
@@ -360,7 +360,9 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_deviceFound(const QString &addres
if (dict.value(QStringLiteral("RSSI")).isValid())
device.setRssi(dict.value(QStringLiteral("RSSI")).toInt());
QList<QBluetoothUuid> uuids;
- foreach (const QString &u, dict.value(QLatin1String("UUIDs")).toStringList())
+ const QStringList uuidStrings
+ = dict.value(QLatin1String("UUIDs")).toStringList();
+ for (const QString &u : uuidStrings)
uuids.append(QBluetoothUuid(u));
device.setServiceUuids(uuids, QBluetoothDeviceInfo::DataIncomplete);
device.setCached(dict.value(QStringLiteral("Cached")).toBool());
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
index fed33bb2..4657da82 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_osx.mm
@@ -553,7 +553,7 @@ QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(
{
if (!deviceAdapter.isNull()) {
const QList<QBluetoothHostInfo> localDevices = QBluetoothLocalDevice::allDevices();
- foreach (const QBluetoothHostInfo &hostInfo, localDevices) {
+ for (const QBluetoothHostInfo &hostInfo : localDevices) {
if (hostInfo.address() == deviceAdapter)
return;
}
diff --git a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
index c247f679..8612fd5c 100644
--- a/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice_bluez.cpp
@@ -249,7 +249,8 @@ QList<QBluetoothHostInfo> QBluetoothLocalDevice::allDevices()
if (reply.isError())
return localDevices;
- foreach (const QDBusObjectPath &path, reply.value()) {
+ const QList<QDBusObjectPath> paths = reply.value();
+ for (const QDBusObjectPath &path : paths) {
QBluetoothHostInfo hostinfo;
OrgBluezAdapterInterface adapter(QStringLiteral("org.bluez"), path.path(),
QDBusConnection::systemBus());
@@ -770,7 +771,8 @@ void QBluetoothLocalDevicePrivate::initializeAdapter()
if (reply.isError())
return;
- foreach (const QDBusObjectPath &path, reply.value()) {
+ const QList<QDBusObjectPath> paths = reply.value();
+ for (const QDBusObjectPath &path : paths) {
OrgBluezAdapterInterface *tmpAdapter
= new OrgBluezAdapterInterface(QStringLiteral("org.bluez"),
path.path(), QDBusConnection::systemBus());
@@ -1067,7 +1069,7 @@ void QBluetoothLocalDevicePrivate::_q_deviceCreated(const QDBusObjectPath &devic
void QBluetoothLocalDevicePrivate::_q_deviceRemoved(const QDBusObjectPath &device)
{
- foreach (OrgBluezDeviceInterface *deviceInterface, devices) {
+ for (OrgBluezDeviceInterface *deviceInterface : qAsConst(devices)) {
if (deviceInterface->path() == device.path()) {
devices.remove(deviceInterface);
delete deviceInterface; // deviceDisconnected is already emitted by _q_devicePropertyChanged
@@ -1113,7 +1115,8 @@ void QBluetoothLocalDevicePrivate::createCache()
qCWarning(QT_BT_BLUEZ) << reply.error().message();
return;
}
- foreach (const QDBusObjectPath &device, reply.value()) {
+ const QList<QDBusObjectPath> knownDevices = reply.value();
+ for (const QDBusObjectPath &device : knownDevices) {
OrgBluezDeviceInterface *deviceInterface =
new OrgBluezDeviceInterface(QStringLiteral("org.bluez"),
device.path(),
diff --git a/src/bluetooth/qbluetoothserver_android.cpp b/src/bluetooth/qbluetoothserver_android.cpp
index b001adb8..3c2cc507 100644
--- a/src/bluetooth/qbluetoothserver_android.cpp
+++ b/src/bluetooth/qbluetoothserver_android.cpp
@@ -142,7 +142,7 @@ bool QBluetoothServer::listen(const QBluetoothAddress &localAdapter, quint16 por
if (!localAdapter.isNull()) {
bool found = false;
- foreach (const QBluetoothHostInfo &hostInfo, localDevices) {
+ for (const QBluetoothHostInfo &hostInfo : localDevices) {
if (hostInfo.address() == localAdapter) {
found = true;
break;
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
index 05d62ab1..e24876e4 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
@@ -177,7 +177,7 @@ QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(const QBluetoot
{
if (!deviceAdapter.isNull()) {
const QList<QBluetoothHostInfo> localDevices = QBluetoothLocalDevice::allDevices();
- foreach (const QBluetoothHostInfo &hostInfo, localDevices) {
+ for (const QBluetoothHostInfo &hostInfo : localDevices) {
if (hostInfo.address() == deviceAdapter)
return;
}
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
index 51db091e..63601058 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
@@ -427,7 +427,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_fetchUuidsTimeout()
QPair<QBluetoothDeviceInfo,QList<QBluetoothUuid> > pair;
const QList<QBluetoothAddress> keys = sdpCache.keys();
- foreach (const QBluetoothAddress &key, keys) {
+ for (const QBluetoothAddress &key : keys) {
pair = sdpCache.take(key);
populateDiscoveredServices(pair.first, pair.second);
}
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
index ea9f354b..82939c26 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_bluez.cpp
@@ -223,7 +223,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::runExternalSdpScan(
// No filter implies PUBLIC_BROWSE_GROUP based SDP scan
if (!uuidFilter.isEmpty()) {
arguments << QLatin1String("-u"); // cmd line option for list of uuids
- foreach (const QBluetoothUuid& uuid, uuidFilter)
+ for (const QBluetoothUuid& uuid : qAsConst(uuidFilter))
arguments << uuid.toString();
}
@@ -286,14 +286,16 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_finishSdpScan(QBluetoothServiceD
errorString = errorDescription;
emit q->error(error);
} else if (!xmlRecords.isEmpty() && discoveryState() != Inactive) {
- foreach (const QString &record, xmlRecords) {
+ for (const QString &record : xmlRecords) {
const QBluetoothServiceInfo serviceInfo = parseServiceXml(record);
//apply uuidFilter
if (!uuidFilter.isEmpty()) {
bool serviceNameMatched = uuidFilter.contains(serviceInfo.serviceUuid());
bool serviceClassMatched = false;
- foreach (const QBluetoothUuid &id, serviceInfo.serviceClassUuids()) {
+ const QList<QBluetoothUuid> serviceClassUuids
+ = serviceInfo.serviceClassUuids();
+ for (const QBluetoothUuid &id : serviceClassUuids) {
if (uuidFilter.contains(id)) {
serviceClassMatched = true;
break;
@@ -519,7 +521,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::discoverServices(const QString &dev
_q_serviceDiscoveryFinished();
} else {
QString pattern;
- foreach (const QBluetoothUuid &uuid, uuidFilter)
+ for (const QBluetoothUuid &uuid : qAsConst(uuidFilter))
pattern += uuid.toString().remove(QLatin1Char('{')).remove(QLatin1Char('}')) + QLatin1Char(' ');
pattern = pattern.trimmed();
@@ -558,13 +560,13 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC
return;
}
- ServiceMap map = reply.value();
+ const ServiceMap map = reply.value();
qCDebug(QT_BT_BLUEZ) << "Parsing xml" << discoveredDevices.at(0).address().toString() << discoveredDevices.count() << map.count();
- foreach (const QString &record, reply.value()) {
+ for (const QString &record : map) {
QBluetoothServiceInfo serviceInfo = parseServiceXml(record);
if (!serviceInfo.isValid())
@@ -578,7 +580,8 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_discoveredServices(QDBusPendingC
// to our own naming resolution.
if (serviceInfo.serviceName().isEmpty()
&& !serviceInfo.serviceClassUuids().isEmpty()) {
- foreach (const QBluetoothUuid &classUuid, serviceInfo.serviceClassUuids()) {
+ const QList<QBluetoothUuid> classUuids = serviceInfo.serviceClassUuids();
+ for (const QBluetoothUuid &classUuid : classUuids) {
bool ok = false;
QBluetoothUuid::ServiceClassUuid clsId
= static_cast<QBluetoothUuid::ServiceClassUuid>(classUuid.toUInt16(&ok));
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
index 1d0cc7da..61d3bcc2 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_osx.mm
@@ -441,7 +441,7 @@ QBluetoothServiceDiscoveryAgent::QBluetoothServiceDiscoveryAgent(const QBluetoot
{
if (!deviceAdapter.isNull()) {
const QList<QBluetoothHostInfo> localDevices = QBluetoothLocalDevice::allDevices();
- foreach (const QBluetoothHostInfo &hostInfo, localDevices) {
+ for (const QBluetoothHostInfo &hostInfo : localDevices) {
if (hostInfo.address() == deviceAdapter)
return;
}
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp
index 77310d01..09523c75 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_winrt.cpp
@@ -537,7 +537,9 @@ void QBluetoothServiceDiscoveryAgentPrivate::processFoundService(quint64 deviceA
if (!uuidFilter.isEmpty()) {
bool serviceNameMatched = uuidFilter.contains(info.serviceUuid());
bool serviceClassMatched = false;
- for (const QBluetoothUuid &id : info.serviceClassUuids()) {
+ const QList<QBluetoothUuid> serviceClassUuids
+ = info.serviceClassUuids();
+ for (const QBluetoothUuid &id : serviceClassUuids) {
if (uuidFilter.contains(id)) {
serviceClassMatched = true;
break;
@@ -553,7 +555,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::processFoundService(quint64 deviceA
QBluetoothServiceInfo returnInfo(info);
bool deviceFound;
- for (const QBluetoothDeviceInfo &deviceInfo : discoveredDevices) {
+ for (const QBluetoothDeviceInfo &deviceInfo : qAsConst(discoveredDevices)) {
if (deviceInfo.address().toUInt64() == deviceAddress) {
deviceFound = true;
returnInfo.setDevice(deviceInfo);
@@ -576,7 +578,7 @@ void QBluetoothServiceDiscoveryAgentPrivate::onScanFinished(quint64 deviceAddres
{
Q_Q(QBluetoothServiceDiscoveryAgent);
bool deviceFound;
- for (const QBluetoothDeviceInfo &deviceInfo : discoveredDevices) {
+ for (const QBluetoothDeviceInfo &deviceInfo : qAsConst(discoveredDevices)) {
if (deviceInfo.address().toUInt64() == deviceAddress) {
deviceFound = true;
discoveredDevices.removeOne(deviceInfo);
diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp
index d706e4a7..d98e616f 100644
--- a/src/bluetooth/qbluetoothserviceinfo.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo.cpp
@@ -606,12 +606,12 @@ static void dumpAttributeVariant(QDebug dbg, const QVariant &var, const QString&
} else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) {
dbg << QString::asprintf("%sSequence\n", indent.toUtf8().constData());
const QBluetoothServiceInfo::Sequence *sequence = static_cast<const QBluetoothServiceInfo::Sequence *>(var.data());
- foreach (const QVariant &v, *sequence)
+ for (const QVariant &v : *sequence)
dumpAttributeVariant(dbg, v, indent + QLatin1Char('\t'));
} else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
dbg << QString::asprintf("%sAlternative\n", indent.toUtf8().constData());
const QBluetoothServiceInfo::Alternative *alternative = static_cast<const QBluetoothServiceInfo::Alternative *>(var.data());
- foreach (const QVariant &v, *alternative)
+ for (const QVariant &v : *alternative)
dumpAttributeVariant(dbg, v, indent + QLatin1Char('\t'));
}
break;
@@ -626,7 +626,8 @@ QDebug operator<<(QDebug dbg, const QBluetoothServiceInfo &info)
{
QDebugStateSaver saver(dbg);
dbg.noquote() << "\n";
- foreach (quint16 id, info.attributes()) {
+ QList<quint16> attributes = info.attributes();
+ for (quint16 id : attributes) {
dumpAttributeVariant(dbg, info.attribute(id), QStringLiteral("(%1)\t").arg(id));
}
return dbg;
@@ -637,7 +638,9 @@ QBluetoothServiceInfo::Sequence QBluetoothServiceInfoPrivate::protocolDescriptor
if (!attributes.contains(QBluetoothServiceInfo::ProtocolDescriptorList))
return QBluetoothServiceInfo::Sequence();
- foreach (const QVariant &v, attributes.value(QBluetoothServiceInfo::ProtocolDescriptorList).value<QBluetoothServiceInfo::Sequence>()) {
+ const QBluetoothServiceInfo::Sequence sequence
+ = attributes.value(QBluetoothServiceInfo::ProtocolDescriptorList).value<QBluetoothServiceInfo::Sequence>();
+ for (const QVariant &v : sequence) {
QBluetoothServiceInfo::Sequence parameters = v.value<QBluetoothServiceInfo::Sequence>();
if (parameters.empty())
continue;
diff --git a/src/bluetooth/qbluetoothserviceinfo_android.cpp b/src/bluetooth/qbluetoothserviceinfo_android.cpp
index 0b46e11b..b0193f73 100644
--- a/src/bluetooth/qbluetoothserviceinfo_android.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_android.cpp
@@ -95,7 +95,7 @@ bool QBluetoothServiceInfoPrivate::registerService(const QBluetoothAddress& loca
if (!localAdapter.isNull()) {
bool found = false;
- foreach (const QBluetoothHostInfo &hostInfo, localDevices) {
+ for (const QBluetoothHostInfo &hostInfo : localDevices) {
if (hostInfo.address() == localAdapter) {
found = true;
break;
diff --git a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp
index 87c715c4..312b5a7a 100644
--- a/src/bluetooth/qbluetoothserviceinfo_bluez.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_bluez.cpp
@@ -158,13 +158,13 @@ static void writeAttribute(QXmlStreamWriter *stream, const QVariant &attribute)
stream->writeStartElement(QStringLiteral("sequence"));
const QBluetoothServiceInfo::Sequence *sequence =
static_cast<const QBluetoothServiceInfo::Sequence *>(attribute.data());
- foreach (const QVariant &v, *sequence)
+ for (const QVariant &v : *sequence)
writeAttribute(stream, v);
stream->writeEndElement();
} else if (attribute.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
const QBluetoothServiceInfo::Alternative *alternative =
static_cast<const QBluetoothServiceInfo::Alternative *>(attribute.data());
- foreach (const QVariant &v, *alternative)
+ for (const QVariant &v : *alternative)
writeAttribute(stream, v);
stream->writeEndElement();
}
diff --git a/src/bluetooth/qbluetoothserviceinfo_osx.mm b/src/bluetooth/qbluetoothserviceinfo_osx.mm
index 755e85c9..27da70fc 100644
--- a/src/bluetooth/qbluetoothserviceinfo_osx.mm
+++ b/src/bluetooth/qbluetoothserviceinfo_osx.mm
@@ -359,12 +359,12 @@ static void dumpAttributeVariant(const QVariant &var, const QString indent)
} else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Sequence>()) {
qDebug("%sSequence", indent.toLocal8Bit().constData());
const QBluetoothServiceInfo::Sequence *sequence = static_cast<const QBluetoothServiceInfo::Sequence *>(var.data());
- foreach (const QVariant &v, *sequence)
+ for (const QVariant &v : *sequence)
dumpAttributeVariant(v, indent + QLatin1Char('\t'));
} else if (var.userType() == qMetaTypeId<QBluetoothServiceInfo::Alternative>()) {
qDebug("%sAlternative", indent.toLocal8Bit().constData());
const QBluetoothServiceInfo::Alternative *alternative = static_cast<const QBluetoothServiceInfo::Alternative *>(var.data());
- foreach (const QVariant &v, *alternative)
+ for (const QVariant &v : *alternative)
dumpAttributeVariant(v, indent + QLatin1Char('\t'));
}
break;
@@ -375,7 +375,8 @@ static void dumpAttributeVariant(const QVariant &var, const QString indent)
QDebug operator << (QDebug dbg, const QBluetoothServiceInfo &info)
{
- foreach (quint16 id, info.attributes()) {
+ const QList<quint16> attributes = info.attributes();
+ for (quint16 id : attributes) {
dumpAttributeVariant(info.attribute(id), QString::fromLatin1("(%1)\t").arg(id));
}
return dbg;
@@ -386,7 +387,9 @@ QBluetoothServiceInfo::Sequence QBluetoothServiceInfoPrivate::protocolDescriptor
if (!attributes.contains(QBluetoothServiceInfo::ProtocolDescriptorList))
return QBluetoothServiceInfo::Sequence();
- foreach (const QVariant &v, attributes.value(QBluetoothServiceInfo::ProtocolDescriptorList).value<QBluetoothServiceInfo::Sequence>()) {
+ const QBluetoothServiceInfo::Sequence sequence
+ = attributes.value(QBluetoothServiceInfo::ProtocolDescriptorList).value<QBluetoothServiceInfo::Sequence>();
+ for (const QVariant &v : sequence) {
QBluetoothServiceInfo::Sequence parameters = v.value<QBluetoothServiceInfo::Sequence>();
if (parameters.empty())
continue;
diff --git a/src/bluetooth/qbluetoothserviceinfo_winrt.cpp b/src/bluetooth/qbluetoothserviceinfo_winrt.cpp
index 5400c001..df3e97b9 100644
--- a/src/bluetooth/qbluetoothserviceinfo_winrt.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo_winrt.cpp
@@ -290,7 +290,7 @@ static ComPtr<IBuffer> bufferFromAttribute(const QVariant &attribute)
HRESULT hr = RoActivateInstance(HString::MakeReference(RuntimeClass_Windows_Storage_Streams_DataWriter).Get(),
&tmpWriter);
Q_ASSERT_SUCCEEDED(hr);
- foreach (const QVariant &v, *sequence) {
+ for (const QVariant &v : *sequence) {
ComPtr<IBuffer> tmpBuffer = bufferFromAttribute(v);
if (!tmpBuffer) {
qCWarning(QT_BT_WINRT) << "Could not create buffer from attribute in sequence";
@@ -468,7 +468,8 @@ bool QBluetoothServiceInfoPrivate::writeSdpAttributes()
ComPtr<IMap<UINT32, IBuffer *>> rawAttributes;
hr = serviceProvider->get_SdpRawAttributes(&rawAttributes);
Q_ASSERT_SUCCEEDED(hr);
- for (quint16 key : attributes.keys()) {
+ const QList<quint16> keys = attributes.keys();
+ for (quint16 key : keys) {
// The SDP Class Id List and RFCOMM and L2CAP protocol descriptors are automatically
// generated by the RfcommServiceProvider. Do not specify it in the SDP raw attribute map.
if (key == QBluetoothServiceInfo::ServiceClassIds
diff --git a/src/bluetooth/qleadvertiser_bluez.cpp b/src/bluetooth/qleadvertiser_bluez.cpp
index bff5a590..47daed25 100644
--- a/src/bluetooth/qleadvertiser_bluez.cpp
+++ b/src/bluetooth/qleadvertiser_bluez.cpp
@@ -273,7 +273,8 @@ void QLeAdvertiserBluez::setServicesData(const QLowEnergyAdvertisingData &src, A
QVector<quint16> services16;
QVector<quint32> services32;
QVector<quint128> services128;
- foreach (const QBluetoothUuid &service, src.services()) {
+ const QList<QBluetoothUuid> services = src.services();
+ for (const QBluetoothUuid &service : services) {
bool ok;
const quint16 service16 = service.toUInt16(&ok);
if (ok) {
@@ -393,7 +394,9 @@ void QLeAdvertiserBluez::setWhiteList()
if (parameters().filterPolicy() == QLowEnergyAdvertisingParameters::IgnoreWhiteList)
return;
queueCommand(OcfLeClearWhiteList, QByteArray());
- foreach (const auto &addressInfo, parameters().whiteList()) {
+ const QList<QLowEnergyAdvertisingParameters::AddressInfo> whiteListInfos
+ = parameters().whiteList();
+ for (const auto &addressInfo : whiteListInfos) {
WhiteListParams commandParam;
static_assert(sizeof commandParam == 7, "unexpected struct size");
commandParam.addrType = addressInfo.type;
diff --git a/src/bluetooth/qlowenergycharacteristic.cpp b/src/bluetooth/qlowenergycharacteristic.cpp
index a8b4c449..82db1c7b 100644
--- a/src/bluetooth/qlowenergycharacteristic.cpp
+++ b/src/bluetooth/qlowenergycharacteristic.cpp
@@ -380,7 +380,7 @@ QList<QLowEnergyDescriptor> QLowEnergyCharacteristic::descriptors() const
std::sort(descriptorKeys.begin(), descriptorKeys.end());
- foreach (const QLowEnergyHandle descHandle, descriptorKeys) {
+ for (const QLowEnergyHandle descHandle : qAsConst(descriptorKeys)) {
QLowEnergyDescriptor descriptor(d_ptr, data->handle, descHandle);
result.append(descriptor);
}
diff --git a/src/bluetooth/qlowenergycharacteristicdata.cpp b/src/bluetooth/qlowenergycharacteristicdata.cpp
index 9e0d69ad..700566a6 100644
--- a/src/bluetooth/qlowenergycharacteristicdata.cpp
+++ b/src/bluetooth/qlowenergycharacteristicdata.cpp
@@ -157,7 +157,7 @@ QList<QLowEnergyDescriptorData> QLowEnergyCharacteristicData::descriptors() cons
void QLowEnergyCharacteristicData::setDescriptors(const QList<QLowEnergyDescriptorData> &descriptors)
{
d->descriptors.clear();
- foreach (const QLowEnergyDescriptorData &desc, descriptors)
+ for (const QLowEnergyDescriptorData &desc : descriptors)
addDescriptor(desc);
}
diff --git a/src/bluetooth/qlowenergycontroller_android.cpp b/src/bluetooth/qlowenergycontroller_android.cpp
index 54665f7b..35d943fc 100644
--- a/src/bluetooth/qlowenergycontroller_android.cpp
+++ b/src/bluetooth/qlowenergycontroller_android.cpp
@@ -501,7 +501,7 @@ void QLowEnergyControllerPrivateAndroid::servicesDiscovered(
if (errorCode == QLowEnergyController::NoError) {
//Android delivers all services in one go
const QStringList list = foundServices.split(QStringLiteral(" "), QString::SkipEmptyParts);
- foreach (const QString &entry, list) {
+ for (const QString &entry : list) {
const QBluetoothUuid service(entry);
if (service.isNull())
return;
@@ -550,7 +550,7 @@ void QLowEnergyControllerPrivateAndroid::serviceDetailsDiscoveryFinished(
const QStringList list = javaIncludes.toString()
.split(QStringLiteral(" "),
QString::SkipEmptyParts);
- foreach (const QString &entry, list) {
+ for (const QString &entry : list) {
const QBluetoothUuid service(entry);
if (service.isNull())
return;
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp
index 502f42ad..7229821e 100644
--- a/src/bluetooth/qlowenergycontroller_bluez.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluez.cpp
@@ -1215,7 +1215,7 @@ void QLowEnergyControllerPrivateBluez::processReply(
lastHandle = parseReadByTypeIncludeDiscovery(
&includedServices, &data[offset], elementLength);
p->includedServices = includedServices;
- foreach (const QBluetoothUuid &uuid, includedServices) {
+ for (const QBluetoothUuid &uuid : qAsConst(includedServices)) {
if (serviceList.contains(uuid))
serviceList[uuid]->type |= QLowEnergyService::IncludedService;
}
@@ -2495,7 +2495,7 @@ void QLowEnergyControllerPrivateBluez::handleReadMultipleRequest(const QByteArra
}
const QVector<Attribute> results = getAttributes(handles.first(), handles.last());
QByteArray response(1, ATT_OP_READ_MULTIPLE_RESPONSE);
- foreach (const Attribute &attr, results) {
+ for (const Attribute &attr : results) {
const int error = checkReadPermissions(attr);
if (error) {
sendErrorResponse(packet.at(0), attr.handle, error);
@@ -2577,7 +2577,7 @@ void QLowEnergyControllerPrivateBluez::updateLocalAttributeValue(
QLowEnergyDescriptor &descriptor)
{
localAttributes[handle].value = value;
- foreach (const auto &service, localServices) {
+ for (const auto &service : qAsConst(localServices)) {
if (handle < service->startHandle || handle > service->endHandle)
continue;
for (auto charIt = service->characteristicList.begin();
@@ -2623,7 +2623,7 @@ void QLowEnergyControllerPrivateBluez::writeCharacteristicForPeripheral(
= attribute.properties & QLowEnergyCharacteristic::Indicate;
if (!hasNotifyProperty && !hasIndicateProperty)
return;
- foreach (const QLowEnergyServicePrivate::DescData &desc, charData.descriptorList) {
+ for (const QLowEnergyServicePrivate::DescData &desc : qAsConst(charData.descriptorList)) {
if (desc.uuid != QBluetoothUuid::ClientCharacteristicConfiguration)
continue;
@@ -2925,7 +2925,7 @@ void QLowEnergyControllerPrivateBluez::handleExecuteWriteRequest(const QByteArra
QVector<QLowEnergyCharacteristic> characteristics;
QVector<QLowEnergyDescriptor> descriptors;
if (!cancel) {
- foreach (const WriteRequest &request, requests) {
+ for (const WriteRequest &request : qAsConst(requests)) {
Attribute &attribute = localAttributes[request.handle];
if (request.valueOffset > attribute.value.count()) {
sendErrorResponse(packet.at(0), request.handle, ATT_ERROR_INVALID_OFFSET);
@@ -2952,9 +2952,9 @@ void QLowEnergyControllerPrivateBluez::handleExecuteWriteRequest(const QByteArra
sendPacket(QByteArray(1, ATT_OP_EXECUTE_WRITE_RESPONSE));
- foreach (const QLowEnergyCharacteristic &characteristic, characteristics)
+ for (const QLowEnergyCharacteristic &characteristic : qAsConst(characteristics))
emit characteristic.d_ptr->characteristicChanged(characteristic, characteristic.value());
- foreach (const QLowEnergyDescriptor &descriptor, descriptors)
+ for (const QLowEnergyDescriptor &descriptor : qAsConst(descriptors))
emit descriptor.d_ptr->descriptorWritten(descriptor, descriptor.value());
}
@@ -3153,7 +3153,7 @@ bool QLowEnergyControllerPrivateBluez::isBonded() const
QVector<QLowEnergyControllerPrivateBluez::TempClientConfigurationData> QLowEnergyControllerPrivateBluez::gatherClientConfigData()
{
QVector<TempClientConfigurationData> data;
- foreach (const auto &service, localServices) {
+ for (const auto &service : qAsConst(localServices)) {
for (auto charIt = service->characteristicList.begin();
charIt != service->characteristicList.end(); ++charIt) {
QLowEnergyServicePrivate::CharData &charData = charIt.value();
@@ -3179,7 +3179,7 @@ void QLowEnergyControllerPrivateBluez::storeClientConfigurations()
}
QVector<ClientConfigurationData> clientConfigs;
const QVector<TempClientConfigurationData> &tempConfigList = gatherClientConfigData();
- foreach (const auto &tempConfigData, tempConfigList) {
+ for (const auto &tempConfigData : tempConfigList) {
Q_ASSERT(tempConfigData.descData->value.count() == 2);
const quint16 value = bt_get_le16(tempConfigData.descData->value.constData());
if (value != 0) {
@@ -3196,9 +3196,9 @@ void QLowEnergyControllerPrivateBluez::restoreClientConfigurations()
const QVector<ClientConfigurationData> &restoredClientConfigs = isBonded()
? clientConfigData.value(remoteDevice.toUInt64()) : QVector<ClientConfigurationData>();
QVector<QLowEnergyHandle> notifications;
- foreach (const auto &tempConfigData, tempConfigList) {
+ for (const auto &tempConfigData : tempConfigList) {
bool wasRestored = false;
- foreach (const auto &restoredData, restoredClientConfigs) {
+ for (const auto &restoredData : restoredClientConfigs) {
if (restoredData.charValueHandle == tempConfigData.charValueHandle) {
Q_ASSERT(tempConfigData.descData->value.count() == 2);
putBtData(restoredData.configValue, tempConfigData.descData->value.data());
@@ -3219,7 +3219,7 @@ void QLowEnergyControllerPrivateBluez::restoreClientConfigurations()
localAttributes[tempConfigData.configHandle].value = tempConfigData.descData->value;
}
- foreach (const QLowEnergyHandle handle, notifications)
+ for (const QLowEnergyHandle handle : qAsConst(notifications))
sendNotification(handle);
sendNextIndication();
}
@@ -3318,7 +3318,8 @@ void QLowEnergyControllerPrivateBluez::addToGenericAttributeList(const QLowEnerg
serviceAttribute.properties = QLowEnergyCharacteristic::Read;
serviceAttribute.value = uuidToByteArray(service.uuid());
QLowEnergyHandle currentHandle = startHandle;
- foreach (const QLowEnergyService * const service, service.includedServices()) {
+ const QList<QLowEnergyService *> includedServices = service.includedServices();
+ for (const QLowEnergyService * const service : includedServices) {
Attribute attribute;
attribute.handle = ++currentHandle;
attribute.type = QBluetoothUuid(GATT_INCLUDED_SERVICE);
@@ -3332,7 +3333,8 @@ void QLowEnergyControllerPrivateBluez::addToGenericAttributeList(const QLowEnerg
putDataAndIncrement(service->serviceUuid(), valueData);
localAttributes[attribute.handle] = attribute;
}
- foreach (const QLowEnergyCharacteristicData &cd, service.characteristics()) {
+ const QList<QLowEnergyCharacteristicData> characteristics = service.characteristics();
+ for (const QLowEnergyCharacteristicData &cd : characteristics) {
Attribute attribute;
// Characteristic declaration;
@@ -3359,7 +3361,8 @@ void QLowEnergyControllerPrivateBluez::addToGenericAttributeList(const QLowEnerg
attribute.maxLength = cd.maximumValueLength();
localAttributes[attribute.handle] = attribute;
- foreach (const QLowEnergyDescriptorData &dd, cd.descriptors()) {
+ const QList<QLowEnergyDescriptorData> descriptors = cd.descriptors();
+ for (const QLowEnergyDescriptorData &dd : descriptors) {
attribute.handle = ++currentHandle;
attribute.groupEndHandle = attribute.handle;
attribute.type = dd.uuid();
diff --git a/src/bluetooth/qlowenergycontroller_osx.mm b/src/bluetooth/qlowenergycontroller_osx.mm
index 2958e6ed..46782a22 100644
--- a/src/bluetooth/qlowenergycontroller_osx.mm
+++ b/src/bluetooth/qlowenergycontroller_osx.mm
@@ -880,7 +880,9 @@ quint16 QLowEnergyControllerPrivateOSX::updateValueOfDescriptor(QLowEnergyHandle
QSharedPointer<QLowEnergyServicePrivate> QLowEnergyControllerPrivateOSX::serviceForHandle(QLowEnergyHandle handle)
{
- foreach (QSharedPointer<QLowEnergyServicePrivate> service, discoveredServices.values()) {
+ const QList<QSharedPointer<QLowEnergyServicePrivate>> services
+ = discoveredServices.values();
+ for (QSharedPointer<QLowEnergyServicePrivate> service : services) {
if (service->startHandle <= handle && handle <= service->endHandle)
return service;
}
@@ -963,7 +965,9 @@ void QLowEnergyControllerPrivateOSX::setErrorDescription(QLowEnergyController::E
void QLowEnergyControllerPrivateOSX::invalidateServices()
{
- foreach (const QSharedPointer<QLowEnergyServicePrivate> service, discoveredServices.values()) {
+ const QList<QSharedPointer<QLowEnergyServicePrivate>> services
+ = discoveredServices.values();
+ for (const QSharedPointer<QLowEnergyServicePrivate> service : services) {
service->setController(nullptr);
service->setState(QLowEnergyService::InvalidService);
}
diff --git a/src/bluetooth/qlowenergycontroller_winrt.cpp b/src/bluetooth/qlowenergycontroller_winrt.cpp
index 917f3790..f6cca42c 100644
--- a/src/bluetooth/qlowenergycontroller_winrt.cpp
+++ b/src/bluetooth/qlowenergycontroller_winrt.cpp
@@ -292,7 +292,7 @@ QLowEnergyControllerPrivateWinRT::~QLowEnergyControllerPrivateWinRT()
mDevice->remove_ConnectionStatusChanged(mStatusChangedToken);
qCDebug(QT_BT_WINRT) << "Unregistering " << mValueChangedTokens.count() << " value change tokens";
- for (const ValueChangedEntry &entry : mValueChangedTokens)
+ for (const ValueChangedEntry &entry : qAsConst(mValueChangedTokens))
entry.characteristic->remove_ValueChanged(entry.token);
}
@@ -469,7 +469,7 @@ void QLowEnergyControllerPrivateWinRT::registerForValueChanges(const QBluetoothU
{
qCDebug(QT_BT_WINRT) << "Registering characteristic" << charUuid << "in service"
<< serviceUuid << "for value changes";
- for (const ValueChangedEntry &entry : mValueChangedTokens) {
+ for (const ValueChangedEntry &entry : qAsConst(mValueChangedTokens)) {
GUID guuid;
HRESULT hr;
hr = entry.characteristic->get_Uuid(&guuid);
@@ -662,7 +662,7 @@ void QLowEnergyControllerPrivateWinRT::discoverServiceDetails(const QBluetoothUu
HRESULT hr;
hr = QEventDispatcherWinRT::runOnXamlThread([indicateChars, service, this]() {
- for (const QBluetoothUuid &indicateChar : indicateChars)
+ for (const QBluetoothUuid &indicateChar : qAsConst(indicateChars))
registerForValueChanges(service, indicateChar);
return S_OK;
});
diff --git a/src/bluetooth/qlowenergycontrollerbase.cpp b/src/bluetooth/qlowenergycontrollerbase.cpp
index c7b9ec0b..8b4c2c10 100644
--- a/src/bluetooth/qlowenergycontrollerbase.cpp
+++ b/src/bluetooth/qlowenergycontrollerbase.cpp
@@ -70,7 +70,7 @@ bool QLowEnergyControllerPrivate::isValidLocalAdapter()
const QList<QBluetoothHostInfo> foundAdapters = QBluetoothLocalDevice::allDevices();
bool adapterFound = false;
- foreach (const QBluetoothHostInfo &info, foundAdapters) {
+ for (const QBluetoothHostInfo &info : foundAdapters) {
if (info.address() == localAdapter) {
adapterFound = true;
break;
@@ -255,7 +255,7 @@ quint16 QLowEnergyControllerPrivate::updateValueOfDescriptor(
void QLowEnergyControllerPrivate::invalidateServices()
{
- foreach (const QSharedPointer<QLowEnergyServicePrivate> service, serviceList.values()) {
+ for (QSharedPointer<QLowEnergyServicePrivate> service : serviceList.values()) {
service->setController(0);
service->setState(QLowEnergyService::InvalidService);
}
@@ -278,7 +278,8 @@ QLowEnergyService *QLowEnergyControllerPrivate::addServiceHelper(
servicePrivate->uuid = service.uuid();
servicePrivate->type = service.type() == QLowEnergyServiceData::ServiceTypePrimary
? QLowEnergyService::PrimaryService : QLowEnergyService::IncludedService;
- foreach (QLowEnergyService * const includedService, service.includedServices()) {
+ const QList<QLowEnergyService *> includedServices = service.includedServices();
+ for (QLowEnergyService * const includedService : includedServices) {
servicePrivate->includedServices << includedService->serviceUuid();
includedService->d_ptr->type |= QLowEnergyService::IncludedService;
}
@@ -287,14 +288,16 @@ QLowEnergyService *QLowEnergyControllerPrivate::addServiceHelper(
const QLowEnergyHandle oldLastHandle = this->lastLocalHandle;
servicePrivate->startHandle = ++this->lastLocalHandle; // Service declaration.
this->lastLocalHandle += servicePrivate->includedServices.count(); // Include declarations.
- foreach (const QLowEnergyCharacteristicData &cd, service.characteristics()) {
+ const QList<QLowEnergyCharacteristicData> characteristics = service.characteristics();
+ for (const QLowEnergyCharacteristicData &cd : characteristics) {
const QLowEnergyHandle declHandle = ++this->lastLocalHandle;
QLowEnergyServicePrivate::CharData charData;
charData.valueHandle = ++this->lastLocalHandle;
charData.uuid = cd.uuid();
charData.properties = cd.properties();
charData.value = cd.value();
- foreach (const QLowEnergyDescriptorData &dd, cd.descriptors()) {
+ const QList<QLowEnergyDescriptorData> descriptors = cd.descriptors();
+ for (const QLowEnergyDescriptorData &dd : descriptors) {
QLowEnergyServicePrivate::DescData descData;
descData.uuid = dd.uuid();
descData.value = dd.value();
diff --git a/src/bluetooth/qlowenergyservice.cpp b/src/bluetooth/qlowenergyservice.cpp
index 357d3901..1529d3c2 100644
--- a/src/bluetooth/qlowenergyservice.cpp
+++ b/src/bluetooth/qlowenergyservice.cpp
@@ -510,7 +510,7 @@ QList<QLowEnergyCharacteristic> QLowEnergyService::characteristics() const
QList<QLowEnergyHandle> handles = d_ptr->characteristicList.keys();
std::sort(handles.begin(), handles.end());
- foreach (const QLowEnergyHandle &handle, handles) {
+ for (const QLowEnergyHandle &handle : qAsConst(handles)) {
QLowEnergyCharacteristic characteristic(d_ptr, handle);
results.append(characteristic);
}
diff --git a/src/bluetooth/qlowenergyservice_osx.mm b/src/bluetooth/qlowenergyservice_osx.mm
index 4423887a..c294b693 100644
--- a/src/bluetooth/qlowenergyservice_osx.mm
+++ b/src/bluetooth/qlowenergyservice_osx.mm
@@ -129,7 +129,7 @@ QList<QLowEnergyCharacteristic> QLowEnergyService::characteristics() const
std::sort(handles.begin(), handles.end());
- foreach (const QLowEnergyHandle &handle, handles) {
+ for (const QLowEnergyHandle &handle : qAsConst(handles)) {
QLowEnergyCharacteristic characteristic(d_ptr, handle);
result.append(characteristic);
}
diff --git a/src/bluetooth/qlowenergyservicedata.cpp b/src/bluetooth/qlowenergyservicedata.cpp
index f40addd2..c536da14 100644
--- a/src/bluetooth/qlowenergyservicedata.cpp
+++ b/src/bluetooth/qlowenergyservicedata.cpp
@@ -170,7 +170,7 @@ QList<QLowEnergyCharacteristicData> QLowEnergyServiceData::characteristics() con
void QLowEnergyServiceData::setCharacteristics(const QList<QLowEnergyCharacteristicData> &characteristics)
{
d->characteristics.clear();
- foreach (const QLowEnergyCharacteristicData &cd, characteristics)
+ for (const QLowEnergyCharacteristicData &cd : characteristics)
addCharacteristic(cd);
}