Various plugins: Fix some more C++20 warnings about [=] captures

Change-Id: If20aac4320c84096a07d67cc137886638286acf8
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Jarek Kobus
2024-02-05 20:50:49 +01:00
parent 97e582c3c0
commit 8bcc78a044
23 changed files with 76 additions and 69 deletions

View File

@@ -80,7 +80,7 @@ DriverSelector::DriverSelector(const QStringList &supportedDrivers, QWidget *par
const auto detailsPanel = new DriverSelectorDetailsPanel(m_selection);
setWidget(detailsPanel);
connect(toolPanel, &DriverSelectorToolPanel::clicked, this, [=] {
connect(toolPanel, &DriverSelectorToolPanel::clicked, this, [this, supportedDrivers] {
DriverSelectionDialog dialog(m_toolsIniFile, supportedDrivers, this);
const int result = dialog.exec();
if (result != QDialog::Accepted)

View File

@@ -1474,7 +1474,7 @@ void ClangdTestHighlighting::test()
const auto lessThan = [=](const TextEditor::HighlightingResult &r, int) {
return Text::positionInText(doc->document(), r.line, r.column) < startPos;
};
const auto findResults = [=] {
const auto findResults = [this, endPos, lessThan, doc] {
TextEditor::HighlightingResults results;
auto it = std::lower_bound(m_results.cbegin(), m_results.cend(), 0, lessThan);
if (it == m_results.cend())

View File

@@ -1196,7 +1196,7 @@ void DiagnosticConfigsWidget::handleChecksAsStringsButtonClicked(BaseChecksTreeM
buttonsBox
}.attachTo(&dialog);
QObject::connect(&dialog, &QDialog::accepted, this, [=, &initialChecks] {
QObject::connect(&dialog, &QDialog::accepted, this, [this, model, textEdit, &initialChecks] {
const QString updatedChecks = textEdit->toPlainText();
if (updatedChecks == initialChecks)
return;

View File

@@ -95,8 +95,8 @@ FilterDialog::FilterDialog(const Checks &checks, QWidget *parent)
buttonBox,
}.attachTo(this);
connect(m_view->selectionModel(), &QItemSelectionModel::selectionChanged, this, [=] {
const bool hasSelection = !this->m_view->selectionModel()->selectedRows().isEmpty();
connect(m_view->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this, buttonBox] {
const bool hasSelection = !m_view->selectionModel()->selectedRows().isEmpty();
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(hasSelection);
});

View File

@@ -554,7 +554,7 @@ void CMakeBuildSettingsWidget::batchEditConfiguration()
connect(buttons, &QDialogButtonBox::accepted, dialog, &QDialog::accept);
connect(buttons, &QDialogButtonBox::rejected, dialog, &QDialog::reject);
connect(dialog, &QDialog::accepted, this, [=]{
connect(dialog, &QDialog::accepted, this, [this, editor] {
const auto expander = m_buildConfig->macroExpander();
const QStringList lines = editor->toPlainText().split('\n', Qt::SkipEmptyParts);
@@ -1012,7 +1012,7 @@ bool CMakeBuildSettingsWidget::eventFilter(QObject *target, QEvent *event)
auto help = new QAction(Tr::tr("Help"), this);
menu->addAction(help);
connect(help, &QAction::triggered, this, [=] {
connect(help, &QAction::triggered, this, [this, idx] {
const CMakeConfigItem item = ConfigModel::dataItemFromIndex(idx).toCMakeConfigItem();
const CMakeTool *tool = CMakeKitAspect::cmakeTool(m_buildConfig->target()->kit());

View File

@@ -322,8 +322,8 @@ QObject *CorePlugin::remoteCommand(const QStringList & /* options */,
{
if (!ExtensionSystem::PluginManager::isInitializationDone()) {
connect(ExtensionSystem::PluginManager::instance(),
&ExtensionSystem::PluginManager::initializationDone,
this, [=] { remoteCommand(QStringList(), workingDirectory, args); });
&ExtensionSystem::PluginManager::initializationDone, this,
[this, workingDirectory, args] { remoteCommand({}, workingDirectory, args); });
return nullptr;
}
const FilePaths filePaths = Utils::transform(args, FilePath::fromUserInput);

View File

@@ -616,12 +616,11 @@ void CppEditorWidget::renameUsages(const QString &replacement, QTextCursor curso
cursor = textCursor();
// First check if the symbol to be renamed comes from a generated file.
LinkHandler continuation = [=, self = QPointer(this)](const Link &link) {
LinkHandler continuation = [this, cursor, replacement, self = QPointer(this)](const Link &link) {
if (!self)
return;
showRenameWarningIfFileIsGenerated(link.targetFilePath);
CursorInEditor cursorInEditor{cursor, textDocument()->filePath(), this, textDocument()};
QPointer<CppEditorWidget> cppEditorWidget = this;
const CursorInEditor cursorInEditor{cursor, textDocument()->filePath(), this, textDocument()};
CppModelManager::globalRename(cursorInEditor, replacement);
};
CppModelManager::followSymbol(CursorInEditor{cursor,
@@ -847,7 +846,8 @@ void CppEditorWidget::renameSymbolUnderCursor()
QPointer<CppEditorWidget> cppEditorWidget = this;
auto renameSymbols = [=](const QString &symbolName, const Links &links, int revision) {
auto renameSymbols = [this, cppEditorWidget](const QString &symbolName, const Links &links,
int revision) {
if (cppEditorWidget) {
viewport()->setCursor(Qt::IBeamCursor);
@@ -1121,8 +1121,8 @@ QMenu *CppEditorWidget::createRefactorMenu(QWidget *parent) const
auto *progressIndicatorMenuItem = new ProgressIndicatorMenuItem(menu);
menu->addAction(progressIndicatorMenuItem);
connect(&d->m_useSelectionsUpdater, &CppUseSelectionsUpdater::finished,
menu, [=] (SemanticInfo::LocalUseMap, bool success) {
connect(&d->m_useSelectionsUpdater, &CppUseSelectionsUpdater::finished, menu,
[this, menu, progressIndicatorMenuItem] (SemanticInfo::LocalUseMap, bool success) {
QTC_CHECK(success);
menu->removeAction(progressIndicatorMenuItem);
addRefactoringActions(menu);

View File

@@ -4783,8 +4783,9 @@ public:
checkbox->setCheckState(Qt::Checked);
};
using Column = CandidateTreeItem::Column;
const auto createConnections = [=](QCheckBox *checkbox, Column column) {
connect(checkbox, &QCheckBox::stateChanged, [setCheckStateForAll, column](int state) {
const auto createConnections = [this, setCheckStateForAll, preventPartiallyChecked](
QCheckBox *checkbox, Column column) {
connect(checkbox, &QCheckBox::stateChanged, this, [setCheckStateForAll, column](int state) {
if (state != Qt::PartiallyChecked)
setCheckStateForAll(column, state);
});

View File

@@ -1397,7 +1397,7 @@ void CdbEngine::fetchMemory(MemoryAgent *agent, quint64 address, quint64 length)
StringInputStream str(args);
str << address << ' ' << length;
cmd.args = args;
cmd.callback = [=](const DebuggerResponse &response) {
cmd.callback = [this, agent, length, address](const DebuggerResponse &response) {
if (!agent)
return;
if (response.resultClass == ResultDone) {

View File

@@ -708,7 +708,8 @@ void FossilClient::annotate(const FilePath &workingDir, const QString &file, int
if (VcsBaseEditorConfig *editorConfig = createAnnotateEditor(fossilEditor)) {
editorConfig->setBaseArguments(extraOptions);
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this, [=] {
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this,
[this, workingDir, file, revision, editorConfig] {
const int line = VcsBaseEditor::lineNumberOfCurrentEditor();
annotate(workingDir, file, line, revision, editorConfig->arguments());
});
@@ -914,7 +915,8 @@ void FossilClient::log(const FilePath &workingDir, const QStringList &files,
if (VcsBaseEditorConfig *editorConfig = createLogEditor(fossilEditor)) {
editorConfig->setBaseArguments(extraOptions);
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this, [=] {
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this,
[this, workingDir, files, editorConfig, enableAnnotationContextMenu, addAuthOptions] {
log(workingDir, files, editorConfig->arguments(), enableAnnotationContextMenu,
addAuthOptions);
});
@@ -969,7 +971,8 @@ void FossilClient::logCurrentFile(const FilePath &workingDir, const QStringList
if (VcsBaseEditorConfig *editorConfig = createLogCurrentFileEditor(fossilEditor)) {
editorConfig->setBaseArguments(extraOptions);
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this, [=] {
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this,
[this, workingDir, files, editorConfig, enableAnnotationContextMenu, addAuthOptions] {
logCurrentFile(workingDir, files, editorConfig->arguments(),
enableAnnotationContextMenu, addAuthOptions);
});

View File

@@ -1055,7 +1055,9 @@ void GitClient::log(const FilePath &workingDirectory, const QString &fileName,
argWidget = new GitLogArgumentsWidget(!fileName.isEmpty(), editor);
argWidget->setBaseArguments(args);
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
[=] { this->log(workingDir, fileName, enableAnnotationContextMenu, args); });
[this, workingDir, fileName, enableAnnotationContextMenu, args] {
log(workingDir, fileName, enableAnnotationContextMenu, args);
});
editor->setEditorConfig(argWidget);
}
editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);
@@ -1112,7 +1114,7 @@ void GitClient::reflog(const FilePath &workingDirectory, const QString &ref)
if (!ref.isEmpty())
argWidget->setBaseArguments({ref});
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
[=] { this->reflog(workingDir, ref); });
[this, workingDir, ref] { reflog(workingDir, ref); });
editor->setEditorConfig(argWidget);
}
editor->setWorkingDirectory(workingDir);
@@ -1222,7 +1224,8 @@ void GitClient::annotate(const Utils::FilePath &workingDir, const QString &file,
if (!argWidget) {
argWidget = new GitBlameArgumentsWidget(editor->toolBar());
argWidget->setBaseArguments(extraOptions);
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this, [=] {
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
[this, workingDir, file, revision, extraOptions] {
const int line = VcsBaseEditor::lineNumberOfCurrentEditor();
annotate(workingDir, file, line, revision, extraOptions);
});
@@ -1248,7 +1251,7 @@ void GitClient::checkout(const FilePath &workingDirectory, const QString &ref, S
return;
const QStringList arguments = setupCheckoutArguments(workingDirectory, ref);
const auto commandHandler = [=](const CommandResult &result) {
const auto commandHandler = [this, stashMode, workingDirectory, handler](const CommandResult &result) {
if (stashMode == StashMode::TryStash)
endStashScope(workingDirectory);
if (result.result() == ProcessResult::FinishedWithSuccess)
@@ -2442,7 +2445,8 @@ void GitClient::tryLaunchingGitK(const Environment &env,
process->setWorkingDirectory(workingDirectory);
process->setEnvironment(env);
process->setCommand({binary, arguments});
connect(process, &Process::done, this, [=] {
connect(process, &Process::done, this,
[this, process, env, workingDirectory, fileName, trial, gitBinDirectory] {
if (process->result() == ProcessResult::StartFailed)
handleGitKFailedToStart(env, workingDirectory, fileName, trial, gitBinDirectory);
process->deleteLater();

View File

@@ -227,7 +227,9 @@ public:
menu->addAction(Tr::tr("&Copy \"%1\"").arg(reference),
[reference] { setClipboardAndSelection(reference); });
QAction *action = menu->addAction(Tr::tr("&Describe Change %1").arg(reference),
[=] { vcsDescribe(workingDirectory, reference); });
[this, workingDirectory, reference] {
vcsDescribe(workingDirectory, reference);
});
menu->setDefaultAction(action);
GitClient::addChangeActions(menu, workingDirectory, reference);
}
@@ -741,7 +743,7 @@ GitPluginPrivate::GitPluginPrivate()
Tr::tr("Update Submodules"), "Git.SubmoduleUpdate",
context, true, std::bind(&GitPluginPrivate::updateSubmodules, this));
auto createAction = [=](const QString &text, Id id,
auto createAction = [this, localRepositoryMenu, context](const QString &text, Id id,
const std::function<void(const FilePath &)> &callback) {
auto actionHandler = [this, callback] {
if (!DocumentManager::saveAllModifiedDocuments())

View File

@@ -100,20 +100,23 @@ QWidget *IosBuildStep::createConfigWidget()
updateDetails();
connect(buildArgumentsTextEdit, &QPlainTextEdit::textChanged, this, [=] {
connect(buildArgumentsTextEdit, &QPlainTextEdit::textChanged, this,
[this, buildArgumentsTextEdit, resetDefaultsButton, updateDetails] {
setBaseArguments(ProcessArgs::splitArgs(buildArgumentsTextEdit->toPlainText(),
HostOsInfo::hostOs()));
resetDefaultsButton->setEnabled(!m_useDefaultArguments);
updateDetails();
});
connect(resetDefaultsButton, &QAbstractButton::clicked, this, [=] {
connect(resetDefaultsButton, &QAbstractButton::clicked, this,
[this, buildArgumentsTextEdit, resetDefaultsButton] {
setBaseArguments(defaultArguments());
buildArgumentsTextEdit->setPlainText(ProcessArgs::joinArgs(baseArguments()));
resetDefaultsButton->setEnabled(!m_useDefaultArguments);
});
connect(extraArgumentsLineEdit, &QLineEdit::editingFinished, this, [=] {
connect(extraArgumentsLineEdit, &QLineEdit::editingFinished, this,
[this, extraArgumentsLineEdit] {
setExtraArguments(ProcessArgs::splitArgs(extraArgumentsLineEdit->text(),
HostOsInfo::hostOs()));
});

View File

@@ -885,7 +885,8 @@ void IosSimulatorToolHandlerPrivate::launchAppOnSimulator(const QStringList &ext
stop(0);
};
auto onResponseAppLaunch = [=](const SimulatorControl::Response &response) {
auto onResponseAppLaunch = [this, captureConsole, monitorPid, stdoutFile, stderrFile](
const SimulatorControl::Response &response) {
if (response) {
if (!isResponseValid(*response))
return;

View File

@@ -105,7 +105,7 @@ public:
}
void sendMessage(const JsonRpcMessage &message)
{
QMetaObject::invokeMethod(m_interface, [=]() { m_interface->sendMessage(message); });
QMetaObject::invokeMethod(m_interface, [this, message] { m_interface->sendMessage(message); });
}
void resetBuffer()
{

View File

@@ -1135,10 +1135,8 @@ public:
group->layout()->addWidget(editor->widget());
layout->addWidget(group);
connect(editor->editorWidget()->textDocument(),
&TextEditor::TextDocument::contentsChanged,
this,
[=] { m_settings.setJson(editor->document()->contents()); });
connect(editor->editorWidget()->textDocument(), &TextEditor::TextDocument::contentsChanged,
this, [this, editor] { m_settings.setJson(editor->document()->contents()); });
}
private:

View File

@@ -114,9 +114,9 @@ void PySideInstaller::installPyside(const FilePath &python,
auto install = new PipInstallTask(python);
connect(install, &PipInstallTask::finished, install, &QObject::deleteLater);
connect(install, &PipInstallTask::finished, this, [=](bool success){
connect(install, &PipInstallTask::finished, this, [this, python, pySide](bool success) {
if (success)
emit this->pySideInstalled(python, pySide);
emit pySideInstalled(python, pySide);
});
if (availablePySides.isEmpty()) {
install->setPackages({PipPackage(pySide)});
@@ -184,7 +184,7 @@ void PySideInstaller::handlePySideMissing(const FilePath &python,
const QString message = Tr::tr("%1 installation missing for %2 (%3)")
.arg(pySide, pythonName(python), python.toUserOutput());
InfoBarEntry info(installPySideInfoBarId, message, InfoBarEntry::GlobalSuppression::Enabled);
auto installCallback = [=] { this->installPyside(python, pySide, document); };
auto installCallback = [this, python, pySide, document] { installPyside(python, pySide, document); };
const QString installTooltip = Tr::tr("Install %1 for %2 using pip package installer.")
.arg(pySide, python.toUserOutput());
info.addCustomButton(Tr::tr("Install"), installCallback, installTooltip);
@@ -204,10 +204,8 @@ void PySideInstaller::runPySideChecker(const FilePath &python,
if (watcher)
watcher->cancel();
});
connect(watcher,
&CheckPySideWatcher::resultReadyAt,
this,
[=, document = QPointer<TextEditor::TextDocument>(document)]() {
connect(watcher, &CheckPySideWatcher::resultReadyAt, this,
[this, watcher, python, pySide, document = QPointer<TextEditor::TextDocument>(document)] {
if (watcher->result())
handlePySideMissing(python, pySide, document);
});

View File

@@ -103,8 +103,9 @@ void PySideBuildStep::checkForPySide(const FilePath &python, const QString &pySi
const PipPackage package(pySidePackageName);
QObject::disconnect(m_watcherConnection);
m_watcher.reset(new QFutureWatcher<PipPackageInfo>());
m_watcherConnection = QObject::connect(m_watcher.get(), &QFutureWatcherBase::finished, this, [=] {
this->handlePySidePackageInfo(m_watcher->result(), python, pySidePackageName);
m_watcherConnection = QObject::connect(m_watcher.get(), &QFutureWatcherBase::finished, this,
[this, python, pySidePackageName] {
handlePySidePackageInfo(m_watcher->result(), python, pySidePackageName);
});
const auto future = Pip::instance(python)->info(package);
m_watcher->setFuture(future);

View File

@@ -283,7 +283,8 @@ void PyLSConfigureAssistant::installPythonLanguageServer(const FilePath &python,
auto install = new PipInstallTask(python);
connect(install, &PipInstallTask::finished, this, [=](const bool success) {
connect(install, &PipInstallTask::finished, this,
[this, python, document, install](const bool success) {
const QList<TextEditor::TextDocument *> additionalDocuments = m_infoBarEntries.take(python);
if (success) {
if (PyLSClient *client = clientForPython(python)) {
@@ -323,10 +324,8 @@ void PyLSConfigureAssistant::openDocument(const FilePath &python, TextEditor::Te
}
});
connect(watcher,
&CheckPylsWatcher::resultReadyAt,
this,
[=, document = QPointer<TextEditor::TextDocument>(document)]() {
connect(watcher, &CheckPylsWatcher::resultReadyAt, this,
[this, watcher, python, document = QPointer<TextEditor::TextDocument>(document)] {
if (!document || !watcher)
return;
handlePyLSState(python, watcher->result(), document);
@@ -355,8 +354,8 @@ void PyLSConfigureAssistant::handlePyLSState(const FilePath &python,
Utils::InfoBarEntry info(installPylsInfoBarId,
message,
Utils::InfoBarEntry::GlobalSuppression::Enabled);
info.addCustomButton(Tr::tr("Install"), [=]() {
this->installPythonLanguageServer(python, document, state.pylsModulePath);
info.addCustomButton(Tr::tr("Install"), [this, python, document, state] {
installPythonLanguageServer(python, document, state.pylsModulePath);
});
infoBar->addInfo(info);
m_infoBarEntries[python] << document;

View File

@@ -346,16 +346,16 @@ void MainWidget::init()
// Connect alignment change
alignToolButton->setProperty("currentAlignment", ActionAlignLeft);
connect(alignToolButton, &QToolButton::clicked, this, [=] {
StateView *view = this->m_views.last();
connect(alignToolButton, &QToolButton::clicked, this, [this, alignToolButton] {
StateView *view = m_views.last();
if (view)
view->scene()->alignStates(alignToolButton->property("currentAlignment").toInt());
});
// Connect alignment change
adjustToolButton->setProperty("currentAdjustment", ActionAdjustWidth);
connect(adjustToolButton, &QToolButton::clicked, this, [=] {
StateView *view = this->m_views.last();
connect(adjustToolButton, &QToolButton::clicked, this, [this, adjustToolButton] {
StateView *view = m_views.last();
if (view)
view->scene()->adjustStates(adjustToolButton->property("currentAdjustment").toInt());
});
@@ -479,7 +479,7 @@ void MainWidget::addStateView(BaseItem *item)
view->scene()->setWarningModel(m_errorPane->warningModel());
view->setUiFactory(m_uiFactory);
connect(view, &QObject::destroyed, this, [=] {
connect(view, &QObject::destroyed, this, [this, view] {
// TODO: un-lambdafy
m_views.removeAll(view);
m_document->popRootTag();

View File

@@ -42,12 +42,12 @@ PaneTitleButton::PaneTitleButton(OutputPane *pane, QWidget *parent)
}
});
connect(pane, &OutputPane::titleChanged, this, [=] {
this->setText(pane->title());
connect(pane, &OutputPane::titleChanged, this, [this, pane] {
setText(pane->title());
});
connect(pane, &OutputPane::iconChanged, this, [=] {
this->setIcon(pane->icon());
connect(pane, &OutputPane::iconChanged, this, [this, pane] {
setIcon(pane->icon());
});
}

View File

@@ -186,7 +186,7 @@ Warning *WarningModel::createWarning(Warning::Severity severity, const QString &
beginInsertRows(QModelIndex(), m_warnings.count(), m_warnings.count());
auto warning = new Warning(severity, type, reason, description, m_warningVisibilities.value(severity, true));
connect(warning, &Warning::destroyed, this, &WarningModel::warningDestroyed);
connect(warning, &Warning::dataChanged, this, [=] {
connect(warning, &Warning::dataChanged, this, [this, warning] {
emit warningsChanged();
QModelIndex ind = createIndex(m_warnings.indexOf(warning), 0);
emit dataChanged(ind, ind);

View File

@@ -413,12 +413,9 @@ void VcsBaseClient::log(const FilePath &workingDir,
if (editorConfig) {
editorConfig->setBaseArguments(extraOptions);
// editor has been just created, createVcsEditor() didn't set a configuration widget yet
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this, [=] {
this->log(workingDir,
files,
extraOptions,
enableAnnotationContextMenu,
addAuthOptions);
connect(editorConfig, &VcsBaseEditorConfig::commandExecutionRequested, this,
[this, workingDir, files, extraOptions, enableAnnotationContextMenu, addAuthOptions] {
log(workingDir, files, extraOptions, enableAnnotationContextMenu, addAuthOptions);
});
editor->setEditorConfig(editorConfig);
}