aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/debugger/watchhandler.cpp
diff options
context:
space:
mode:
authorTobias Hunger <[email protected]>2020-01-20 09:45:26 +0100
committerTobias Hunger <[email protected]>2020-01-20 10:00:36 +0000
commit5995569063e128085e58ab621af33cf8291b9aff (patch)
tree2da37fd51edc71b299355103189a5398e63b5c2f /src/plugins/debugger/watchhandler.cpp
parent8f130039e31128d845aae8cc75169e59f0809368 (diff)
Debugger: Avoid potential nullptr access
Item may be a nullptr, so do not access it. Change-Id: I3fdbe30dbbd451027c23c9ed06f08396f0ce215a Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins/debugger/watchhandler.cpp')
-rw-r--r--src/plugins/debugger/watchhandler.cpp51
1 files changed, 23 insertions, 28 deletions
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index d2cbacaa2d7..9c402087bc6 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -1693,28 +1693,22 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
menu->addMenu(createBreakpointMenu(item, menu));
menu->addSeparator();
- addAction(menu, tr("Expand All Children"),
- item,
- [this, name = item->iname] {
- m_expandedINames.insert(name);
- if (auto item = findItem(name)) {
- item->forFirstLevelChildren([this](WatchItem *child) {
- m_expandedINames.insert(child->iname);
- });
- m_engine->updateLocals();
- }
- });
+ 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); });
+ m_engine->updateLocals();
+ }
+ });
- addAction(menu, tr("Collapse All Children"),
- item,
- [this, name = item->iname] {
- if (auto item = findItem(name)) {
- item->forFirstLevelChildren([this](WatchItem *child) {
- m_expandedINames.remove(child->iname);
- });
- m_engine->updateLocals();
- }
- });
+ 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); });
+ m_engine->updateLocals();
+ }
+ });
addAction(menu, tr("Close Editor Tooltips"),
m_engine->toolTipManager()->hasToolTips(),
@@ -1724,16 +1718,17 @@ 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] {
- if (auto item = findItem(name))
- copyToClipboard(item->value);
+ [this, name = item ? item->iname : QString()] {
+ if (auto item = findItem(name))
+ copyToClipboard(item->value);
});
-// addAction(menu, tr("Copy Selected Rows to Clipboard"),
-// selectionModel()->hasSelection(),
-// [this] { copyToClipboard(editorContents(selectionModel()->selectedRows())); });
+ // addAction(menu, tr("Copy Selected Rows to Clipboard"),
+ // selectionModel()->hasSelection(),
+ // [this] { copyToClipboard(editorContents(selectionModel()->selectedRows())); });
addAction(menu, tr("Open View Contents in Editor"),
m_engine->debuggerActionsEnabled(),