From 24397509d4b6c4e63b5f11ab846d71051248f64b Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Tue, 12 Dec 2023 12:12:36 +0100 Subject: [PATCH] Libs: Cleanup lambdas Change-Id: I715a124dd73f23c735dde27d3205ac7613ae04c6 Reviewed-by: hjk --- src/libs/extensionsystem/pluginmanager.cpp | 6 +++--- src/libs/qmldebug/qmlenginecontrolclient.cpp | 4 ++-- src/libs/qmljs/qmljsscanner.cpp | 2 +- src/libs/tracing/timelineabstractrenderer.cpp | 6 +++--- src/libs/utils/aspects.cpp | 12 ++++++------ src/libs/utils/devicefileaccess.cpp | 2 +- src/libs/utils/fancylineedit.cpp | 2 +- src/libs/utils/terminalhooks.cpp | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index 267a144cf76..c8c09ec5c27 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -864,7 +864,7 @@ bool PluginManager::finishScenario() if (d->m_isScenarioFinished.exchange(true)) return false; // Finish was already called before. We return false, as we didn't finish it right now. - QMetaObject::invokeMethod(d, []() { emit m_instance->scenarioFinished(0); }); + QMetaObject::invokeMethod(d, [] { emit m_instance->scenarioFinished(0); }); return true; // Finished successfully. } @@ -975,7 +975,7 @@ void PluginManagerPrivate::startDelayedInitialize() const QString info = QString("Successfully started scenario \"%1\"...").arg(d->m_requestedScenario); qInfo("%s", qPrintable(info)); } else { - QMetaObject::invokeMethod(this, []() { emit m_instance->scenarioFinished(1); }); + QMetaObject::invokeMethod(this, [] { emit m_instance->scenarioFinished(1); }); } } #endif @@ -1304,7 +1304,7 @@ void PluginManagerPrivate::startTests() failedTests += executeTestPlan(testPlan); } - QTimer::singleShot(0, this, [failedTests]() { emit m_instance->testsFinished(failedTests); }); + QTimer::singleShot(0, this, [failedTests] { emit m_instance->testsFinished(failedTests); }); } #endif diff --git a/src/libs/qmldebug/qmlenginecontrolclient.cpp b/src/libs/qmldebug/qmlenginecontrolclient.cpp index 4672cc45ba1..a9db9f79a2c 100644 --- a/src/libs/qmldebug/qmlenginecontrolclient.cpp +++ b/src/libs/qmldebug/qmlenginecontrolclient.cpp @@ -76,7 +76,7 @@ void QmlEngineControlClient::messageReceived(const QByteArray &data) switch (message) { case EngineAboutToBeAdded: - handleWaiting(StartWaitingEngine, [&](){ + handleWaiting(StartWaitingEngine, [this, id, name] { emit engineAboutToBeAdded(id, name); }); break; @@ -84,7 +84,7 @@ void QmlEngineControlClient::messageReceived(const QByteArray &data) emit engineAdded(id, name); break; case EngineAboutToBeRemoved: - handleWaiting(StopWaitingEngine, [&](){ + handleWaiting(StopWaitingEngine, [this, id, name] { emit engineAboutToBeRemoved(id, name); }); break; diff --git a/src/libs/qmljs/qmljsscanner.cpp b/src/libs/qmljs/qmljsscanner.cpp index c94d12ed5bf..aa076a7ea7b 100644 --- a/src/libs/qmljs/qmljsscanner.cpp +++ b/src/libs/qmljs/qmljsscanner.cpp @@ -541,7 +541,7 @@ bool Scanner::isKeyword(const QString &text) const QStringList Scanner::keywords() { - static QStringList words = []() { + static QStringList words = [] { QStringList res; for (const QString *word = begin(js_keywords); word != end(js_keywords); ++word) res.append(*word); diff --git a/src/libs/tracing/timelineabstractrenderer.cpp b/src/libs/tracing/timelineabstractrenderer.cpp index 5fc0cd34b57..acfa4890915 100644 --- a/src/libs/tracing/timelineabstractrenderer.cpp +++ b/src/libs/tracing/timelineabstractrenderer.cpp @@ -99,7 +99,7 @@ void TimelineAbstractRenderer::setModel(TimelineModel *model) this, &TimelineAbstractRenderer::setRowHeightsDirty); connect(d->model, &TimelineModel::contentChanged, this, &TimelineAbstractRenderer::setModelDirty); - connect(d->model, &QObject::destroyed, this, [this, d]() { + connect(d->model, &QObject::destroyed, this, [this, d] { // Weak pointers are supposed to be notified before the destroyed() signal is sent. Q_ASSERT(d->model.isNull()); d->renderPasses.clear(); @@ -135,7 +135,7 @@ void TimelineAbstractRenderer::setNotes(TimelineNotesModel *notes) if (d->notes) { connect(d->notes, &TimelineNotesModel::changed, this, &TimelineAbstractRenderer::setNotesDirty); - connect(d->notes, &QObject::destroyed, this, [this, d]() { + connect(d->notes, &QObject::destroyed, this, [this, d] { // Weak pointers are supposed to be notified before the destroyed() signal is sent. Q_ASSERT(d->notes.isNull()); setNotesDirty(); @@ -164,7 +164,7 @@ void TimelineAbstractRenderer::setZoomer(TimelineZoomControl *zoomer) d->zoomer = zoomer; if (d->zoomer) { connect(d->zoomer, &TimelineZoomControl::windowChanged, this, &QQuickItem::update); - connect(d->zoomer, &QObject::destroyed, this, [this, d]() { + connect(d->zoomer, &QObject::destroyed, this, [this, d] { // Weak pointers are supposed to be notified before the destroyed() signal is sent. Q_ASSERT(d->zoomer.isNull()); emit zoomerChanged(d->zoomer); diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index 259df760577..e329c0d56ca 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -1158,7 +1158,7 @@ void StringAspect::addToLayout(LayoutItem &parent) connect(d->m_checkerImpl.m_checked.get(), &BoolAspect::volatileValueChanged, lineEditDisplay, - [this, lineEditDisplay]() { + [this, lineEditDisplay] { d->m_checkerImpl.updateWidgetFromCheckStatus(this, lineEditDisplay); }); } @@ -1185,12 +1185,12 @@ void StringAspect::addToLayout(LayoutItem &parent) connect(lineEditDisplay, &FancyLineEdit::editingFinished, this, - [this, lineEditDisplay]() { + [this, lineEditDisplay] { d->undoable.set(undoStack(), lineEditDisplay->text()); handleGuiChanged(); }); } else { - connect(lineEditDisplay, &QLineEdit::textChanged, this, [this, lineEditDisplay]() { + connect(lineEditDisplay, &QLineEdit::textChanged, this, [this, lineEditDisplay] { d->undoable.set(undoStack(), lineEditDisplay->text()); handleGuiChanged(); }); @@ -1235,7 +1235,7 @@ void StringAspect::addToLayout(LayoutItem &parent) connect(d->m_checkerImpl.m_checked.get(), &BoolAspect::volatileValueChanged, textEditDisplay, - [this, textEditDisplay]() { + [this, textEditDisplay] { d->m_checkerImpl.updateWidgetFromCheckStatus(this, textEditDisplay); }); } @@ -1252,7 +1252,7 @@ void StringAspect::addToLayout(LayoutItem &parent) textEditDisplay, &QTextEdit::setPlaceholderText); - connect(textEditDisplay, &QTextEdit::textChanged, this, [this, textEditDisplay]() { + connect(textEditDisplay, &QTextEdit::textChanged, this, [this, textEditDisplay] { if (textEditDisplay->toPlainText() != d->undoable.get()) { d->undoable.set(undoStack(), textEditDisplay->toPlainText()); handleGuiChanged(); @@ -3549,7 +3549,7 @@ void StringSelectionAspect::addToLayout(Layouting::LayoutItem &parent) bufferToGui(); }); - connect(&m_undoable.m_signal, &UndoSignaller::changed, comboBox, [this, comboBox]() { + connect(&m_undoable.m_signal, &UndoSignaller::changed, comboBox, [this, comboBox] { auto item = itemById(m_undoable.get()); if (item) m_selectionModel->setCurrentIndex(item->index(), QItemSelectionModel::ClearAndSelect); diff --git a/src/libs/utils/devicefileaccess.cpp b/src/libs/utils/devicefileaccess.cpp index 82e6a24a71d..5fdd17a7e13 100644 --- a/src/libs/utils/devicefileaccess.cpp +++ b/src/libs/utils/devicefileaccess.cpp @@ -232,7 +232,7 @@ expected_str DeviceFileAccess::copyRecursively(const FilePath &src, QObject::connect(&srcProcess, &Process::readyReadStandardOutput, &targetProcess, - [&srcProcess, &targetProcess]() { + [&srcProcess, &targetProcess] { targetProcess.writeRaw(srcProcess.readAllRawStandardOutput()); }); diff --git a/src/libs/utils/fancylineedit.cpp b/src/libs/utils/fancylineedit.cpp index a3acaad0f44..dc75fed6b9c 100644 --- a/src/libs/utils/fancylineedit.cpp +++ b/src/libs/utils/fancylineedit.cpp @@ -571,7 +571,7 @@ void FancyLineEdit::validate() connect(d->m_validatorWatcher.get(), &QFutureWatcher::finished, this, - [this, oldText]() { + [this, oldText] { FancyLineEdit::AsyncValidationResult result = d->m_validatorWatcher->result(); handleValidationResult(result, oldText); diff --git a/src/libs/utils/terminalhooks.cpp b/src/libs/utils/terminalhooks.cpp index bb517cb9554..52bcc056295 100644 --- a/src/libs/utils/terminalhooks.cpp +++ b/src/libs/utils/terminalhooks.cpp @@ -42,7 +42,7 @@ public: FilePath{}), parameters.environment.value_or(Environment{})); }; - auto createProcessInterface = []() { return new ExternalTerminalProcessImpl(); }; + auto createProcessInterface = [] { return new ExternalTerminalProcessImpl; }; addCallbackSet("External", {openTerminal, createProcessInterface}); }