Debugger: Pass context object to lambda connections

Remove some unneeded lambda () brackets.
Glue lambda brackets with parameters brackets.

Change-Id: I5df67cf01e497ad39c070a3f138a647762f2c33c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-12-07 23:20:02 +01:00
parent 448471a399
commit fc6b7996b8
7 changed files with 19 additions and 24 deletions

View File

@@ -948,9 +948,7 @@ void CdbEngine::runCommand(const DebuggerCommand &dbgCmd)
QString cmd = dbgCmd.function + dbgCmd.argsToString(); QString cmd = dbgCmd.function + dbgCmd.argsToString();
if (!m_accessible) { if (!m_accessible) {
doInterruptInferior([this, dbgCmd](){ doInterruptInferior([this, dbgCmd] { runCommand(dbgCmd); });
runCommand(dbgCmd);
});
const QString msg = QString("Attempt to issue command \"%1\" to non-accessible session (%2)... interrupting") const QString msg = QString("Attempt to issue command \"%1\" to non-accessible session (%2)... interrupting")
.arg(cmd, stateName(state())); .arg(cmd, stateName(state()));
showMessage(msg, LogMisc); showMessage(msg, LogMisc);
@@ -1412,7 +1410,7 @@ void CdbEngine::fetchMemory(MemoryAgent *agent, quint64 address, quint64 length)
StringInputStream str(args); StringInputStream str(args);
str << address << ' ' << length; str << address << ' ' << length;
cmd.args = args; cmd.args = args;
cmd.callback = [=] (const DebuggerResponse &response) { cmd.callback = [=](const DebuggerResponse &response) {
if (!agent) if (!agent)
return; return;
if (response.resultClass == ResultDone) { if (response.resultClass == ResultDone) {

View File

@@ -604,14 +604,10 @@ StartRemoteCdbDialog::StartRemoteCdbDialog(QWidget *parent) :
m_okButton = box->button(QDialogButtonBox::Ok); m_okButton = box->button(QDialogButtonBox::Ok);
m_okButton->setEnabled(false); m_okButton->setEnabled(false);
connect(m_lineEdit, &QLineEdit::textChanged, connect(m_lineEdit, &QLineEdit::textChanged, this, &StartRemoteCdbDialog::textChanged);
this, &StartRemoteCdbDialog::textChanged); connect(m_lineEdit, &QLineEdit::returnPressed, m_okButton, &QAbstractButton::animateClick);
connect(m_lineEdit, &QLineEdit::returnPressed, connect(box, &QDialogButtonBox::accepted, this, &StartRemoteCdbDialog::accept);
[this] { m_okButton->animateClick(); }); connect(box, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(box, &QDialogButtonBox::accepted,
this, &StartRemoteCdbDialog::accept);
connect(box, &QDialogButtonBox::rejected,
this, &QDialog::reject);
} }
void StartRemoteCdbDialog::accept() void StartRemoteCdbDialog::accept()

View File

@@ -796,9 +796,9 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
vbox->insertWidget(0, label); vbox->insertWidget(0, label);
}; };
const auto addFontSizeAdaptation = [](QWidget *widget) { const auto addFontSizeAdaptation = [this](QWidget *widget) {
QObject::connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged, QObject::connect(TextEditorSettings::instance(), &TextEditorSettings::fontSettingsChanged,
[widget](const FontSettings &settings) { this, [widget](const FontSettings &settings) {
if (!debuggerSettings()->fontSizeFollowsEditor.value()) if (!debuggerSettings()->fontSizeFollowsEditor.value())
return; return;
qreal size = settings.fontZoom() * settings.fontSize() / 100.; qreal size = settings.fontZoom() * settings.fontSize() / 100.;
@@ -1148,7 +1148,8 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(const QStringList &arguments)
DebuggerMainWindow::leaveDebugMode(); DebuggerMainWindow::leaveDebugMode();
}); });
connect(ModeManager::instance(), &ModeManager::currentModeChanged, [](Id mode, Id oldMode) { connect(ModeManager::instance(), &ModeManager::currentModeChanged,
this, [](Id mode, Id oldMode) {
QTC_ASSERT(mode != oldMode, return); QTC_ASSERT(mode != oldMode, return);
if (mode == MODE_DEBUG) { if (mode == MODE_DEBUG) {
DebuggerMainWindow::enterDebugMode(); DebuggerMainWindow::enterDebugMode();
@@ -1876,7 +1877,7 @@ void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget,
: Tr::tr("Set Breakpoint at Line %1").arg(lineNumber); : Tr::tr("Set Breakpoint at Line %1").arg(lineNumber);
auto act = menu->addAction(text); auto act = menu->addAction(text);
act->setEnabled(args.isValid()); act->setEnabled(args.isValid());
connect(act, &QAction::triggered, [this, args] { connect(act, &QAction::triggered, this, [this, args] {
breakpointSetMarginActionTriggered(false, args); breakpointSetMarginActionTriggered(false, args);
}); });
@@ -1886,7 +1887,7 @@ void DebuggerPluginPrivate::requestContextMenu(TextEditorWidget *widget,
: Tr::tr("Set Message Tracepoint at Line %1...").arg(lineNumber); : Tr::tr("Set Message Tracepoint at Line %1...").arg(lineNumber);
act = menu->addAction(tracePointText); act = menu->addAction(tracePointText);
act->setEnabled(args.isValid()); act->setEnabled(args.isValid());
connect(act, &QAction::triggered, [this, args] { connect(act, &QAction::triggered, this, [this, args] {
breakpointSetMarginActionTriggered(true, args); breakpointSetMarginActionTriggered(true, args);
}); });
} }

View File

@@ -771,7 +771,7 @@ DebuggerToolTipHolder::DebuggerToolTipHolder(const DebuggerToolTipContext &conte
state = New; state = New;
QObject::connect(widget->pinButton, &QAbstractButton::clicked, [this] { QObject::connect(widget->pinButton, &QAbstractButton::clicked, widget, [this] {
if (widget->isPinned) if (widget->isPinned)
widget->close(); widget->close();
else else
@@ -1194,7 +1194,7 @@ void DebuggerToolTipManagerPrivate::slotTooltipOverrideRequested
context.expression = localVariable->name; context.expression = localVariable->name;
context.iname = localVariable->iname; context.iname = localVariable->iname;
auto reusable = [context] (DebuggerToolTipHolder *tooltip) { auto reusable = [context](DebuggerToolTipHolder *tooltip) {
return tooltip->context.isSame(context); return tooltip->context.isSame(context);
}; };
DebuggerToolTipHolder *tooltip = Utils::findOrDefault(m_tooltips, reusable); DebuggerToolTipHolder *tooltip = Utils::findOrDefault(m_tooltips, reusable);
@@ -1215,7 +1215,7 @@ void DebuggerToolTipManagerPrivate::slotTooltipOverrideRequested
} else { } else {
context.iname = "tooltip." + toHex(context.expression); context.iname = "tooltip." + toHex(context.expression);
auto reusable = [context] (DebuggerToolTipHolder *tooltip) { auto reusable = [context](DebuggerToolTipHolder *tooltip) {
return tooltip->context.isSame(context); return tooltip->context.isSame(context);
}; };
DebuggerToolTipHolder *tooltip = Utils::findOrDefault(m_tooltips, reusable); DebuggerToolTipHolder *tooltip = Utils::findOrDefault(m_tooltips, reusable);

View File

@@ -445,7 +445,7 @@ void EngineManager::deactivateDebugMode()
// "previously active application"), doing the switch synchronously // "previously active application"), doing the switch synchronously
// leads to funny effects with floating dock widgets // leads to funny effects with floating dock widgets
const Utils::Id mode = d->m_previousMode; const Utils::Id mode = d->m_previousMode;
QTimer::singleShot(0, d, [mode]() { ModeManager::activateMode(mode); }); QTimer::singleShot(0, d, [mode] { ModeManager::activateMode(mode); });
d->m_previousMode = Id(); d->m_previousMode = Id();
} }
} }

View File

@@ -38,7 +38,7 @@ LocalsAndInspectorWindow::LocalsAndInspectorWindow(QWidget *locals,
// when debugger engine changes states. // when debugger engine changes states.
m_timer.setSingleShot(true); m_timer.setSingleShot(true);
m_timer.setInterval(500); // TODO: remove the magic number! m_timer.setInterval(500); // TODO: remove the magic number!
connect(&m_timer, &QTimer::timeout, [this, localsAndInspector] { connect(&m_timer, &QTimer::timeout, this, [this, localsAndInspector] {
localsAndInspector->setCurrentIndex(m_showLocals ? LocalsIndex : InspectorIndex); localsAndInspector->setCurrentIndex(m_showLocals ? LocalsIndex : InspectorIndex);
}); });
} }

View File

@@ -719,7 +719,7 @@ void UvscEngine::handleUpdateLocals(bool partial)
watchHandler()->appendFormatRequests(&cmd); watchHandler()->appendFormatRequests(&cmd);
watchHandler()->appendWatchersAndTooltipRequests(&cmd); watchHandler()->appendWatchersAndTooltipRequests(&cmd);
auto enumerateExpandedINames = [&cmd]() { auto enumerateExpandedINames = [&cmd] {
QStringList inames; QStringList inames;
const QJsonArray array = cmd.args["expanded"].toArray(); const QJsonArray array = cmd.args["expanded"].toArray();
for (const QJsonValue &value : array) for (const QJsonValue &value : array)
@@ -727,7 +727,7 @@ void UvscEngine::handleUpdateLocals(bool partial)
return inames; return inames;
}; };
auto enumerateRootWatchers = [&cmd]() { auto enumerateRootWatchers = [&cmd] {
std::vector<std::pair<QString, QString>> inames; std::vector<std::pair<QString, QString>> inames;
const QJsonArray array = cmd.args["watchers"].toArray(); const QJsonArray array = cmd.args["watchers"].toArray();
for (const QJsonValue &value : array) { for (const QJsonValue &value : array) {