From 6f025cddd28f7e96fb1a39a557acae2eef8cf2d6 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Wed, 20 Mar 2024 14:23:19 -0700 Subject: [PATCH] Fix exception when disposing sim sequencers (#9919) (#9928) --- pxtsim/sound/sequencer.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pxtsim/sound/sequencer.ts b/pxtsim/sound/sequencer.ts index dd07851b072c..f96b3b432690 100644 --- a/pxtsim/sound/sequencer.ts +++ b/pxtsim/sound/sequencer.ts @@ -41,6 +41,7 @@ namespace pxsim.music { dispose() { if (this.metronome) this.metronome.dispose(); + this.metronome = undefined this.stop(); this.currentlyPlaying = undefined; this.listeners = {}; @@ -84,7 +85,7 @@ namespace pxsim.music { stop(sustainCurrentSounds = false) { if (this._state === "stop") return; this._state = "stop"; - this.metronome.stop(); + if (this.metronome) this.metronome.stop(); this.fireStateChange(); if (!sustainCurrentSounds) this.currentCancelToken.cancelled = true;