Skip to content

Commit 27143f1

Browse files
committed
another list memory leak
1 parent 008f5b2 commit 27143f1

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# GG Changelog
22

3+
## Unreleased
4+
5+
### Fixed
6+
- Another memory leak (failure to deregister RAF callbacks).
7+
- Some broken graph rendering (which was relying on the previous leak!).
8+
39
## [0.35.0](releases/tag/v0.35.0)
410
This release is based on Jujutsu 0.35.
511

src/GraphLog.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@
7373
});
7474
}
7575
76+
function getKey(row: EnhancedRow | null) {
77+
if (!row) return null;
78+
const lineKeys = row.passingLines.map((l) => l.key).join(":");
79+
return `${row.revision.id.commit.hex}:${lineKeys}`;
80+
}
81+
7682
$: graphHeight = Math.max(containerHeight, rows.length * rowHeight);
7783
$: visibleRows = Math.ceil(containerHeight / rowHeight) + 1;
7884
$: startIndex = Math.floor(Math.max(scrollTop, 0) / rowHeight);
@@ -86,7 +92,7 @@
8692

8793
<svg class="graph" style="width: 100%; height: {graphHeight}px;">
8894
{#each visibleSlice.rows as row, i}
89-
{#key row?.revision.id.commit.hex ?? i}
95+
{#key getKey(row) ?? i}
9096
<g transform="translate({(row?.location[0] ?? 0) * columnWidth} {(row?.location[1] ?? 0) * rowHeight})">
9197
<foreignObject
9298
class:placeholder={row === null}
@@ -104,7 +110,7 @@
104110
{/each}
105111

106112
{#each visibleSlice.rows as row, i}
107-
{#key row?.revision.id.commit.hex ?? i}
113+
{#key getKey(row) ?? i}
108114
{#each distinctLines(visibleSlice.keys, row) as line}
109115
<GraphLine {line} />
110116
{/each}

src/controls/ListWidget.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
3030
onMount(() => {
3131
pollFrame = requestAnimationFrame(pollScroll);
32+
return () => {
33+
if (pollFrame) cancelAnimationFrame(pollFrame);
34+
};
3235
});
3336
3437
function pollScroll() {

0 commit comments

Comments
 (0)