summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2019-12-13 13:51:00 +0100
committerChristian Stenger <christian.stenger@qt.io>2019-12-17 08:10:03 +0000
commite3338f2e8ac6cf48a6d75a463e04c0aa7a24511d (patch)
treef87da86c238adf59b3b80da19f9b872b69823184
parent7e4cd9b3684b05b1a711e980bf43c0474267d21e (diff)
downloadqt-creator-e3338f2e8ac6cf48a6d75a463e04c0aa7a24511d.tar.gz
Debugger: Avoid accessing nullptr
If the context menu is spawned while stepping the user may be able to trigger some actions that try to access an item that had been present before, but after the stepping the items inside the tree view usually got completely re-created. Change-Id: I80029bc1272cfc8b78fe0ed5b1e0f36f29920631 Reviewed-by: hjk <hjk@qt.io>
-rw-r--r--src/plugins/debugger/watchhandler.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp
index a254036bf1..21656ec4fe 100644
--- a/src/plugins/debugger/watchhandler.cpp
+++ b/src/plugins/debugger/watchhandler.cpp
@@ -1680,21 +1680,25 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
addAction(menu, tr("Expand All Children"),
item,
- [this, item] {
- m_expandedINames.insert(item->iname);
- item->forFirstLevelChildren([this](WatchItem *child) {
- m_expandedINames.insert(child->iname);
- });
- m_engine->updateLocals();
+ [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("Collapse All Children"),
item,
- [this, item] {
- item->forFirstLevelChildren([this](WatchItem *child) {
- m_expandedINames.remove(child->iname);
- });
- m_engine->updateLocals();
+ [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("Close Editor Tooltips"),
@@ -1707,7 +1711,10 @@ bool WatchModel::contextMenuEvent(const ItemViewEvent &ev)
addAction(menu, tr("Copy Current Value to Clipboard"),
item,
- [item] { copyToClipboard(item->value); });
+ [this, name = item->iname] {
+ if (auto item = findItem(name))
+ copyToClipboard(item->value);
+ });
// addAction(menu, tr("Copy Selected Rows to Clipboard"),
// selectionModel()->hasSelection(),