Fix exception on shutdown

Improve error handling during shutdown
This commit is contained in:
Flamefire committed 2014-10-16 19:08:20 +02:00
1 parent 2371eb4344
commit b8bd9bf87b
4 files changed
+12 -6

No files matched your search

+1 -1
View File
@@ -130,7 +130,7 @@ namespace Vocaluxe.Base
_Initialized = true; _Initialized = true;
} }
public static void CloseAll() public static void Close()
{ {
if (_Initialized) if (_Initialized)
{ {
+1 -1
View File
@@ -57,7 +57,7 @@ namespace Vocaluxe.Base.ThemeSystem
public static void Unload() public static void Unload()
{ {
foreach (CBaseTheme theme in _Themes) foreach (CTheme theme in _Themes)
theme.Unload(); theme.Unload();
CurrentThemes.Clear(); CurrentThemes.Clear();
} }
+1 -2
View File
@@ -117,7 +117,7 @@ namespace Vocaluxe.Lib.Sound.Playback
{ {
if (!_Initialized) if (!_Initialized)
return -1; return -1;
IAudioStream stream = _CreateStream(_NextID, medium, loop); IAudioStream stream = _CreateStream(_NextID++, medium, loop);
if (stream.Open(prescan)) if (stream.Open(prescan))
{ {
@@ -127,7 +127,6 @@ namespace Vocaluxe.Lib.Sound.Playback
stream.VolumeMax = _GlobalVolume; stream.VolumeMax = _GlobalVolume;
stream.SetOnCloseListener(this); stream.SetOnCloseListener(this);
_Streams.Add(stream); _Streams.Add(stream);
_NextID++;
return stream.ID; return stream.ID;
} }
} }
+9 -2
View File
@@ -279,8 +279,15 @@ namespace Vocaluxe
CRecord.Close(); CRecord.Close();
CSound.Close(); CSound.Close();
CDraw.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) {} catch (Exception) {}
Environment.Exit(Environment.ExitCode); Environment.Exit(Environment.ExitCode);