From c3259fc2dfe4a1db9b683d0626088e9dbe263de2 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 1 Jul 2020 04:07:33 +0200 Subject: [PATCH] Solve some clazy warnings My last patch triggered me to run clazy on the project. This patch solves some of them: - Proper iteration of some types, saving their copy. - compile-time connects - prefer using connects with the 3rd argument as an object when using lambdas. --- src/declarativeimports/core/tooltipdialog.cpp | 2 +- src/plasma/pluginloader.cpp | 5 ++--- src/plasmaquick/appletquickitem.cpp | 2 +- src/scriptengines/qml/plasmoid/containmentinterface.cpp | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/declarativeimports/core/tooltipdialog.cpp b/src/declarativeimports/core/tooltipdialog.cpp index 5e50032c4..23cd10d93 100644 --- a/src/declarativeimports/core/tooltipdialog.cpp +++ b/src/declarativeimports/core/tooltipdialog.cpp @@ -26,7 +26,7 @@ ToolTipDialog::ToolTipDialog(QQuickItem *parent) m_showTimer = new QTimer(this); m_showTimer->setSingleShot(true); - connect(m_showTimer, &QTimer::timeout, [ = ]() { + connect(m_showTimer, &QTimer::timeout, this, [this]() { setVisible(false); }); } diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index 68c952672..dcadba504 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -121,9 +121,8 @@ PluginLoader::PluginLoader() PluginLoader::~PluginLoader() { - typedef QPointer pswp; - for (pswp wp : qAsConst(d->structures)) { - delete wp.data(); + for (const auto &wp : qAsConst(d->structures)) { + delete wp; } delete d; } diff --git a/src/plasmaquick/appletquickitem.cpp b/src/plasmaquick/appletquickitem.cpp index c59d87456..595707f33 100644 --- a/src/plasmaquick/appletquickitem.cpp +++ b/src/plasmaquick/appletquickitem.cpp @@ -596,7 +596,7 @@ void AppletQuickItem::init() reason = d->applet->launchErrorMessage(); } else if (d->applet->kPackage().isValid()) { const auto errors = d->qmlObject->mainComponent()->errors(); - for (QQmlError error : errors) { + for (const QQmlError &error : errors) { reason += error.toString() + QLatin1Char('\n'); } reason = i18n("Error loading QML file: %1", reason); diff --git a/src/scriptengines/qml/plasmoid/containmentinterface.cpp b/src/scriptengines/qml/plasmoid/containmentinterface.cpp index 064d7388f..ffba89e4f 100644 --- a/src/scriptengines/qml/plasmoid/containmentinterface.cpp +++ b/src/scriptengines/qml/plasmoid/containmentinterface.cpp @@ -482,8 +482,8 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI job->setParent(m_dropMenu.data()); QObject::connect(job, &KJob::result, this, &ContainmentInterface::dropJobResult); - QObject::connect(job, SIGNAL(mimetype(KIO::Job*, QString)), - this, SLOT(mimeTypeRetrieved(KIO::Job*,QString))); + QObject::connect(job, QOverload::of(&KIO::MimetypeJob::mimetype), + this, &ContainmentInterface::mimeTypeRetrieved); } else { bool deleteDropMenu = true;