| 1165 | // ── Find the root-level struct ancestor for a node ── |
| 1166 | |
| 1167 | uint64_t MainWindow::findRootStructForNode(const NodeTree& tree, uint64_t nodeId) const { |
| 1168 | QSet<uint64_t> visited; |
| 1169 | uint64_t cur = nodeId; |
| 1170 | uint64_t lastStruct = 0; |
| 1171 | while (cur != 0 && !visited.contains(cur)) { |
| 1172 | visited.insert(cur); |
| 1173 | int idx = tree.indexOfId(cur); |
| 1174 | if (idx < 0) break; |
| 1175 | const Node& n = tree.nodes[idx]; |
| 1176 | if (n.kind == NodeKind::Struct) |
| 1177 | lastStruct = n.id; |
| 1178 | if (n.parentId == 0) |
| 1179 | return (n.kind == NodeKind::Struct) ? n.id : lastStruct; |
| 1180 | cur = n.parentId; |
| 1181 | } |
| 1182 | return lastStruct; |
| 1183 | } |
| 1184 | |
| 1185 | // ── Update the rendered view for a single pane ── |
| 1186 | |