From 6df7f18a3b56df281909e54cd09fc0dddc937ca6 Mon Sep 17 00:00:00 2001 From: rob-v Date: Thu, 22 Jun 2017 18:03:15 +0200 Subject: [PATCH] Fix Initialize sounds (dispose of null SoundSource) --- OpenRA.Game/Sound/Sound.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenRA.Game/Sound/Sound.cs b/OpenRA.Game/Sound/Sound.cs index 5a776eed1b..f05c1d7d7d 100644 --- a/OpenRA.Game/Sound/Sound.cs +++ b/OpenRA.Game/Sound/Sound.cs @@ -88,14 +88,12 @@ namespace OpenRA if (sounds != null) foreach (var soundSource in sounds.Values) - soundSource.Dispose(); + if (soundSource != null) + soundSource.Dispose(); getSoundSource = s => LoadSound(loaders, fileSystem, s); sounds = new Cache(getSoundSource); currentSounds = new Dictionary(); - music = null; - musicSource = null; - currentMusic = null; video = null; } @@ -236,13 +234,15 @@ namespace OpenRA { soundEngine.StopSound(music); soundEngine.ReleaseSound(music); - music = null; - musicSource.Dispose(); - musicSource = null; } - MusicPlaying = false; + if (musicSource != null) + musicSource.Dispose(); + + music = null; + musicSource = null; currentMusic = null; + MusicPlaying = false; } public void PauseMusic()