From 78fe0c315ee18358f0aa2bc3452d3d19efac73b4 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Fri, 5 May 2023 12:26:48 +0200 Subject: [PATCH] Debugger: fix vanishing editor tooltip on expand fetchMore is called multiple times before expandNode and seems to invalidate the index that is passed to expandNode. Since we only need to fetch more when we want to expand the item we might as well just integrate the code of fetch more into expandNode. Fixes: QTCREATORBUG-29083 Change-Id: I0e60e9bb03b53de2e86eea232fb5bb98046bbb80 Reviewed-by: hjk --- .../debugger/debuggertooltipmanager.cpp | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index f5e9933fbef..70e52355867 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -266,9 +266,20 @@ public: void expandNode(const QModelIndex &idx) { + if (!m_engine) + return; + m_expandedINames.insert(idx.data(LocalsINameRole).toString()); - if (canFetchMore(idx)) - fetchMore(idx); + if (canFetchMore(idx)) { + if (!idx.isValid()) + return; + + if (auto item = dynamic_cast(itemForIndex(idx))) { + WatchItem *it = m_engine->watchHandler()->findItem(item->iname); + if (QTC_GUARD(it)) + it->model()->fetchMore(it->index()); + } + } } void collapseNode(const QModelIndex &idx) @@ -276,22 +287,6 @@ public: m_expandedINames.remove(idx.data(LocalsINameRole).toString()); } - void fetchMore(const QModelIndex &idx) override - { - if (!idx.isValid()) - return; - auto item = dynamic_cast(itemForIndex(idx)); - if (!item) - return; - QString iname = item->iname; - if (!m_engine) - return; - - WatchItem *it = m_engine->watchHandler()->findItem(iname); - QTC_ASSERT(it, return); - it->model()->fetchMore(it->index()); - } - void restoreTreeModel(QXmlStreamReader &r); QPointer m_engine;