Debugger: Avoid potential nullptr access

Item may be a nullptr, so do not access it.

Change-Id: I3fdbe30dbbd451027c23c9ed06f08396f0ce215a
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Tobias Hunger
2020-01-20 09:45:26 +01:00
parent 8f130039e3
commit 5995569063

View File

@@ -1693,25 +1693,19 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
menu->addMenu(createBreakpointMenu(item, menu));
menu->addSeparator();
addAction(menu, tr("Expand All Children"),
item,
[this, name = item->iname] {
addAction(menu, tr("Expand All Children"), item, [this, name = item ? item->iname : QString()] {
m_expandedINames.insert(name);
if (auto item = findItem(name)) {
item->forFirstLevelChildren([this](WatchItem *child) {
m_expandedINames.insert(child->iname);
});
item->forFirstLevelChildren(
[this](WatchItem *child) { m_expandedINames.insert(child->iname); });
m_engine->updateLocals();
}
});
addAction(menu, tr("Collapse All Children"),
item,
[this, name = item->iname] {
addAction(menu, tr("Collapse All Children"), item, [this, name = item ? item->iname : QString()] {
if (auto item = findItem(name)) {
item->forFirstLevelChildren([this](WatchItem *child) {
m_expandedINames.remove(child->iname);
});
item->forFirstLevelChildren(
[this](WatchItem *child) { m_expandedINames.remove(child->iname); });
m_engine->updateLocals();
}
});
@@ -1724,9 +1718,10 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
true,
[this] { copyToClipboard(editorContents()); });
addAction(menu, tr("Copy Current Value to Clipboard"),
addAction(menu,
tr("Copy Current Value to Clipboard"),
item,
[this, name = item->iname] {
[this, name = item ? item->iname : QString()] {
if (auto item = findItem(name))
copyToClipboard(item->value);
});