forked from qt-creator/qt-creator
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:
@@ -1693,28 +1693,22 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
|
|||||||
menu->addMenu(createBreakpointMenu(item, menu));
|
menu->addMenu(createBreakpointMenu(item, menu));
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
addAction(menu, tr("Expand All Children"),
|
addAction(menu, tr("Expand All Children"), item, [this, name = item ? item->iname : QString()] {
|
||||||
item,
|
m_expandedINames.insert(name);
|
||||||
[this, name = item->iname] {
|
if (auto item = findItem(name)) {
|
||||||
m_expandedINames.insert(name);
|
item->forFirstLevelChildren(
|
||||||
if (auto item = findItem(name)) {
|
[this](WatchItem *child) { m_expandedINames.insert(child->iname); });
|
||||||
item->forFirstLevelChildren([this](WatchItem *child) {
|
m_engine->updateLocals();
|
||||||
m_expandedINames.insert(child->iname);
|
}
|
||||||
});
|
});
|
||||||
m_engine->updateLocals();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addAction(menu, tr("Collapse All Children"),
|
addAction(menu, tr("Collapse All Children"), item, [this, name = item ? item->iname : QString()] {
|
||||||
item,
|
if (auto item = findItem(name)) {
|
||||||
[this, name = item->iname] {
|
item->forFirstLevelChildren(
|
||||||
if (auto item = findItem(name)) {
|
[this](WatchItem *child) { m_expandedINames.remove(child->iname); });
|
||||||
item->forFirstLevelChildren([this](WatchItem *child) {
|
m_engine->updateLocals();
|
||||||
m_expandedINames.remove(child->iname);
|
}
|
||||||
});
|
});
|
||||||
m_engine->updateLocals();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
addAction(menu, tr("Close Editor Tooltips"),
|
addAction(menu, tr("Close Editor Tooltips"),
|
||||||
m_engine->toolTipManager()->hasToolTips(),
|
m_engine->toolTipManager()->hasToolTips(),
|
||||||
@@ -1724,16 +1718,17 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
|
|||||||
true,
|
true,
|
||||||
[this] { copyToClipboard(editorContents()); });
|
[this] { copyToClipboard(editorContents()); });
|
||||||
|
|
||||||
addAction(menu, tr("Copy Current Value to Clipboard"),
|
addAction(menu,
|
||||||
|
tr("Copy Current Value to Clipboard"),
|
||||||
item,
|
item,
|
||||||
[this, name = item->iname] {
|
[this, name = item ? item->iname : QString()] {
|
||||||
if (auto item = findItem(name))
|
if (auto item = findItem(name))
|
||||||
copyToClipboard(item->value);
|
copyToClipboard(item->value);
|
||||||
});
|
});
|
||||||
|
|
||||||
// addAction(menu, tr("Copy Selected Rows to Clipboard"),
|
// addAction(menu, tr("Copy Selected Rows to Clipboard"),
|
||||||
// selectionModel()->hasSelection(),
|
// selectionModel()->hasSelection(),
|
||||||
// [this] { copyToClipboard(editorContents(selectionModel()->selectedRows())); });
|
// [this] { copyToClipboard(editorContents(selectionModel()->selectedRows())); });
|
||||||
|
|
||||||
addAction(menu, tr("Open View Contents in Editor"),
|
addAction(menu, tr("Open View Contents in Editor"),
|
||||||
m_engine->debuggerActionsEnabled(),
|
m_engine->debuggerActionsEnabled(),
|
||||||
|
|||||||
Reference in New Issue
Block a user