Fix cursor jump on command row edit, data-change highlighting for containers, invalid pointer expansion, cycle detection with node IDs, O(n²) addNode cache, duplicate struct in C++ export, collapse bug for non-first root structs, remove hardcoded demo data

This commit is contained in:
megablocks(tm)
2026-02-07 12:02:41 -07:00
committed by sysadmin
parent 39cac316de
commit 9962e55820
7 changed files with 225 additions and 169 deletions

View File

@@ -240,9 +240,11 @@ struct NodeTree {
Node copy = n;
if (copy.id == 0) copy.id = m_nextId++;
else if (copy.id >= m_nextId) m_nextId = copy.id + 1;
int idx = nodes.size();
nodes.append(copy);
m_idCache.clear();
return nodes.size() - 1;
if (!m_idCache.isEmpty())
m_idCache[copy.id] = idx;
return idx;
}
// Reserve a unique ID atomically (for use before pushing undo commands)
@@ -297,11 +299,12 @@ struct NodeTree {
int depthOf(int idx) const {
int d = 0;
QSet<int> visited;
QSet<uint64_t> visited;
int cur = idx;
while (cur >= 0 && cur < nodes.size() && nodes[cur].parentId != 0) {
if (visited.contains(cur)) break;
visited.insert(cur);
uint64_t nid = nodes[cur].id;
if (visited.contains(nid)) break;
visited.insert(nid);
cur = indexOfId(nodes[cur].parentId);
if (cur < 0) break;
d++;
@@ -311,11 +314,12 @@ struct NodeTree {
int64_t computeOffset(int idx) const {
int64_t total = 0;
QSet<int> visited;
QSet<uint64_t> visited;
int cur = idx;
while (cur >= 0 && cur < nodes.size()) {
if (visited.contains(cur)) break;
visited.insert(cur);
uint64_t nid = nodes[cur].id;
if (visited.contains(nid)) break;
visited.insert(nid);
total += nodes[cur].offset;
if (nodes[cur].parentId == 0) break;
cur = indexOfId(nodes[cur].parentId);