Skip to content

Commit d5f1c57

Browse files
committed
Inspector: Fix bad RemoteObjectGraphModel::parent_index()
We were returning bogus indices and also failing to handle parents that are roots. This was visible in the broken line trees drawn by GTreeView.
1 parent 797e132 commit d5f1c57

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

DevTools/Inspector/RemoteObjectGraphModel.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,19 @@ GModelIndex RemoteObjectGraphModel::parent_index(const GModelIndex& index) const
3636
auto& remote_object = *static_cast<RemoteObject*>(index.internal_data());
3737
if (!remote_object.parent)
3838
return {};
39-
for (int row = 0; row < remote_object.parent->children.size(); ++row) {
40-
if (&remote_object.parent->children[row] == &remote_object)
39+
40+
// NOTE: If the parent has no parent, it's a root, so we have to look among the remote roots.
41+
if (!remote_object.parent->parent) {
42+
for (int row = 0; row < m_process.roots().size(); ++row) {
43+
if (&m_process.roots()[row] == remote_object.parent)
44+
return create_index(row, 0, remote_object.parent);
45+
}
46+
ASSERT_NOT_REACHED();
47+
return {};
48+
}
49+
50+
for (int row = 0; row < remote_object.parent->parent->children.size(); ++row) {
51+
if (&remote_object.parent->parent->children[row] == remote_object.parent)
4152
return create_index(row, 0, remote_object.parent);
4253
}
4354

0 commit comments

Comments
 (0)