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>
This commit is contained in:
Christian Stenger
2019-12-13 13:51:00 +01:00
parent 7e4cd9b368
commit e3338f2e8a

View File

@@ -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(),