From e9c812c29c493beb4476db8d74beefc6b6656c2e Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Sat, 18 Dec 2021 00:30:20 +0100 Subject: [PATCH] Use Timer.Spawn instead of TimerComp timers when disposing MIDI Renderers. - Fixes a bug where renderers are not disposed of correctly when the instrument entity is deleted. --- Content.Client/Instruments/InstrumentSystem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Content.Client/Instruments/InstrumentSystem.cs b/Content.Client/Instruments/InstrumentSystem.cs index 05e2049cf1..13f8c982f2 100644 --- a/Content.Client/Instruments/InstrumentSystem.cs +++ b/Content.Client/Instruments/InstrumentSystem.cs @@ -129,7 +129,8 @@ namespace Content.Client.Instruments var renderer = instrument.Renderer; // We dispose of the synth two seconds from now to allow the last notes to stop from playing. - instrument.Owner.SpawnTimer(2000, () => { renderer?.Dispose(); }); + // Don't use timers bound to the entity in case it is getting deleted. + Timer.Spawn(2000, () => { renderer?.Dispose(); }); instrument.Renderer = null; instrument.MidiEventBuffer.Clear();