forked from qt-creator/qt-creator
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:
@@ -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(),
|
||||
|
Reference in New Issue
Block a user