Skip to content

Commit

Permalink
Fix notefield/waveform memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tillvit committed Nov 17, 2024
1 parent e4e9bfe commit 580687a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions app/src/chart/component/edit/Waveform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ export class Waveform extends Sprite implements ChartRendererComponent {
)
this.trackVariable(() => this.renderer.chartManager.chartAudio.hasFilters())

const onUpdate = () => this.getData()

this.anchor.set(0.5)
this.renderer.chartManager.chartAudio.onUpdate(() => this.getData())
this.renderer.chartManager.chartAudio.onUpdate(onUpdate)
this.getData()
this.resizeWaveform()

Expand All @@ -131,7 +133,7 @@ export class Waveform extends Sprite implements ChartRendererComponent {
const audioChanged = () => {
this.getData()
this.resizeWaveform()
this.renderer.chartManager.chartAudio.onUpdate(() => this.getData())
this.renderer.chartManager.chartAudio.onUpdate(onUpdate)
}
EventHandler.on("timingModified", timingHandler)
this.on("destroyed", () => {
Expand All @@ -140,6 +142,7 @@ export class Waveform extends Sprite implements ChartRendererComponent {
EventHandler.on("audioLoaded", audioChanged)
this.on("destroyed", () => {
EventHandler.off("audioLoaded", audioChanged)
this.renderer.chartManager.chartAudio.offUpdate(onUpdate)
})
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/chart/component/notefield/NoteContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class NoteContainer extends Container {
EventHandler.on("chartModified", purgeNotes)
this.on("destroyed", () => {
EventHandler.off("timeSigChanged", timeSig)
EventHandler.on("chartModified", purgeNotes)
EventHandler.off("chartModified", purgeNotes)
})
}

Expand Down

0 comments on commit 580687a

Please sign in to comment.