From b8bd9bf87bac53f455a57fdc5fa3ddf9138538ac Mon Sep 17 00:00:00 2001 From: Flamefire Date: Thu, 16 Oct 2014 19:08:20 +0200 Subject: [PATCH] Fix exception on shutdown Improve error handling during shutdown --- Vocaluxe/Base/CLog.cs | 2 +- Vocaluxe/Base/ThemeSystem/CThemes.cs | 2 +- Vocaluxe/Lib/Sound/Playback/CPlaybackBase.cs | 3 +-- Vocaluxe/Program.cs | 11 +++++++++-- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Vocaluxe/Base/CLog.cs b/Vocaluxe/Base/CLog.cs index 31d26f5a..f91b9d00 100644 --- a/Vocaluxe/Base/CLog.cs +++ b/Vocaluxe/Base/CLog.cs @@ -130,7 +130,7 @@ namespace Vocaluxe.Base _Initialized = true; } - public static void CloseAll() + public static void Close() { if (_Initialized) { diff --git a/Vocaluxe/Base/ThemeSystem/CThemes.cs b/Vocaluxe/Base/ThemeSystem/CThemes.cs index 1190c85e..a39f2d23 100644 --- a/Vocaluxe/Base/ThemeSystem/CThemes.cs +++ b/Vocaluxe/Base/ThemeSystem/CThemes.cs @@ -57,7 +57,7 @@ namespace Vocaluxe.Base.ThemeSystem public static void Unload() { - foreach (CBaseTheme theme in _Themes) + foreach (CTheme theme in _Themes) theme.Unload(); CurrentThemes.Clear(); } diff --git a/Vocaluxe/Lib/Sound/Playback/CPlaybackBase.cs b/Vocaluxe/Lib/Sound/Playback/CPlaybackBase.cs index a9ce5959..dc702c8b 100644 --- a/Vocaluxe/Lib/Sound/Playback/CPlaybackBase.cs +++ b/Vocaluxe/Lib/Sound/Playback/CPlaybackBase.cs @@ -117,7 +117,7 @@ namespace Vocaluxe.Lib.Sound.Playback { if (!_Initialized) return -1; - IAudioStream stream = _CreateStream(_NextID, medium, loop); + IAudioStream stream = _CreateStream(_NextID++, medium, loop); if (stream.Open(prescan)) { @@ -127,7 +127,6 @@ namespace Vocaluxe.Lib.Sound.Playback stream.VolumeMax = _GlobalVolume; stream.SetOnCloseListener(this); _Streams.Add(stream); - _NextID++; return stream.ID; } } diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 8686be54..a00fbba6 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -279,8 +279,15 @@ namespace Vocaluxe CRecord.Close(); CSound.Close(); CDraw.Close(); - GC.Collect(); // Do a GC run here before we close logs to have finalizers run - CLog.CloseAll(); // Do this last, so we get all log entries! + } + catch (Exception e) + { + CLog.LogError("Error during shutdown!", false, false, e); + } + GC.Collect(); // Do a GC run here before we close logs to have finalizers run + try + { + CLog.Close(); // Do this last, so we get all log entries! } catch (Exception) {} Environment.Exit(Environment.ExitCode);