From bd17dc2041f15d5fae4d9277643edd7c743f6e3f Mon Sep 17 00:00:00 2001 From: Nicolas Fella Date: Sun, 25 Nov 2018 23:58:24 +0100 Subject: [PATCH] Fix container detach warnings from clazy Reviewers: #kde_connect, apol Reviewed By: #kde_connect, apol Subscribers: apol, kdeconnect Tags: #kde_connect Differential Revision: https://phabricator.kde.org/D17164 --- cli/kdeconnect-cli.cpp | 3 ++- core/daemon.cpp | 2 +- core/device.cpp | 2 +- interfaces/remotesinksmodel.cpp | 4 ++-- plugins/sendnotifications/sendnotifications_config.cpp | 5 +++-- plugins/systemvolume/systemvolumeplugin-pulse.cpp | 6 ++++-- tests/testsocketlinereader.cpp | 2 +- tests/testsslsocketlinereader.cpp | 4 ++-- 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/cli/kdeconnect-cli.cpp b/cli/kdeconnect-cli.cpp index a42a1cacc..2b5e4de25 100644 --- a/cli/kdeconnect-cli.cpp +++ b/cli/kdeconnect-cli.cpp @@ -152,7 +152,8 @@ int main(int argc, char** argv) urls.append(url); // Check for more arguments - for (const QString& input : parser.positionalArguments()) { + const auto args = parser.positionalArguments(); + for (const QString& input : args) { QUrl url = QUrl::fromUserInput(input, QDir::currentPath()); urls.append(url); } diff --git a/core/daemon.cpp b/core/daemon.cpp index e52335465..51acc9231 100644 --- a/core/daemon.cpp +++ b/core/daemon.cpp @@ -289,7 +289,7 @@ void Daemon::addDevice(Device* device) QStringList Daemon::pairingRequests() const { QStringList ret; - for(Device* dev: d->m_devices) { + for(Device* dev: qAsConst(d->m_devices)) { if (dev->hasPairingRequests()) ret += dev->id(); } diff --git a/core/device.cpp b/core/device.cpp index 8f5805e84..1dd0f59b7 100644 --- a/core/device.cpp +++ b/core/device.cpp @@ -441,7 +441,7 @@ void Device::cleanUnneededLinks() { QHostAddress Device::getLocalIpAddress() const { - for (DeviceLink* dl : d->m_deviceLinks) { + for (DeviceLink* dl : qAsConst(d->m_deviceLinks)) { LanDeviceLink* ldl = dynamic_cast(dl); if (ldl) { return ldl->hostAddress(); diff --git a/interfaces/remotesinksmodel.cpp b/interfaces/remotesinksmodel.cpp index 8ef9f1630..48adc96bd 100644 --- a/interfaces/remotesinksmodel.cpp +++ b/interfaces/remotesinksmodel.cpp @@ -76,7 +76,7 @@ void RemoteSinksModel::setDeviceId(const QString& deviceId) this, &RemoteSinksModel::refreshSinkList); connect(m_dbusInterface, &OrgKdeKdeconnectDeviceRemotesystemvolumeInterface::volumeChanged, this, [this](const QString& name, int volume) { - for (Sink* s: m_sinkList) { + for (Sink* s: qAsConst(m_sinkList)) { if (s->name == name) { s->volume = volume; Q_EMIT dataChanged(index(0,0), index(m_sinkList.size() - 1, 0)); @@ -85,7 +85,7 @@ void RemoteSinksModel::setDeviceId(const QString& deviceId) }); connect(m_dbusInterface, &OrgKdeKdeconnectDeviceRemotesystemvolumeInterface::mutedChanged, this, [this](const QString& name, bool muted) { - for (Sink* s: m_sinkList) { + for (Sink* s: qAsConst(m_sinkList)) { if (s->name == name) { s->muted = muted; Q_EMIT dataChanged(index(0,0), index(m_sinkList.size() - 1, 0)); diff --git a/plugins/sendnotifications/sendnotifications_config.cpp b/plugins/sendnotifications/sendnotifications_config.cpp index 55645bbee..d6126b5d7 100644 --- a/plugins/sendnotifications/sendnotifications_config.cpp +++ b/plugins/sendnotifications/sendnotifications_config.cpp @@ -109,8 +109,9 @@ void SendNotificationsConfig::save() config()->set(QStringLiteral("generalUrgency"), m_ui->spin_urgency->value()); QVariantList list; - list.reserve(appModel->apps().size()); - for (const auto& a: appModel->apps()) { + const auto apps = appModel->apps(); + list.reserve(apps.size()); + for (const auto& a: apps) { list.append(QVariant::fromValue(a)); } config()->setList(QStringLiteral("applications"), list); diff --git a/plugins/systemvolume/systemvolumeplugin-pulse.cpp b/plugins/systemvolume/systemvolumeplugin-pulse.cpp index 3b37d7761..772a0295f 100644 --- a/plugins/systemvolume/systemvolumeplugin-pulse.cpp +++ b/plugins/systemvolume/systemvolumeplugin-pulse.cpp @@ -74,7 +74,8 @@ void SystemvolumePlugin::sendSinkList() { sinksMap.clear(); - for (PulseAudioQt::Sink* sink : PulseAudioQt::Context::instance()->sinks()) { + const auto sinks = PulseAudioQt::Context::instance()->sinks(); + for (PulseAudioQt::Sink* sink : sinks) { sinksMap.insert(sink->name(), sink); connect(sink, &PulseAudioQt::Sink::volumeChanged, this, [this, sink] { @@ -118,7 +119,8 @@ void SystemvolumePlugin::connected() sendSinkList(); }); - for (PulseAudioQt::Sink* sink : PulseAudioQt::Context::instance()->sinks()) { + const auto sinks = PulseAudioQt::Context::instance()->sinks(); + for (PulseAudioQt::Sink* sink : sinks) { sinksMap.insert(sink->name(), sink); } } diff --git a/tests/testsocketlinereader.cpp b/tests/testsocketlinereader.cpp index 1c42f0aff..09ae12d7b 100644 --- a/tests/testsocketlinereader.cpp +++ b/tests/testsocketlinereader.cpp @@ -67,7 +67,7 @@ void TestSocketLineReader::socketLineReader() { QList dataToSend; dataToSend << "foobar\n" << "barfoo\n" << "foobar?\n" << "\n" << "barfoo!\n" << "panda\n"; - for (const QByteArray& line : dataToSend) { + for (const QByteArray& line : qAsConst(dataToSend)) { m_conn->write(line); } m_conn->flush(); diff --git a/tests/testsslsocketlinereader.cpp b/tests/testsslsocketlinereader.cpp index fe90edf3c..10e5a1aeb 100644 --- a/tests/testsslsocketlinereader.cpp +++ b/tests/testsslsocketlinereader.cpp @@ -138,7 +138,7 @@ void TestSslSocketLineReader::testTrustedDevice() QList dataToSend; dataToSend << "foobar\n" << "barfoo\n" << "foobar?\n" << "\n" << "barfoo!\n" << "panda\n"; - for (const QByteArray& line : dataToSend) { + for (const QByteArray& line : qAsConst(dataToSend)) { m_clientSocket->write(line); } m_clientSocket->flush(); @@ -197,7 +197,7 @@ void TestSslSocketLineReader::testUntrustedDevice() QList dataToSend; dataToSend << "foobar\n" << "barfoo\n" << "foobar?\n" << "\n" << "barfoo!\n" << "panda\n"; - for (const QByteArray& line : dataToSend) { + for (const QByteArray& line : qAsConst(dataToSend)) { m_clientSocket->write(line); } m_clientSocket->flush();