From 55849376bae565fdead90b29252047256c04b3e8 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 16 Apr 2013 16:47:38 +0200 Subject: [PATCH] Fixed crash with faulty song files --- VocaluxeLib/Menu/SongMenu/CSong.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/VocaluxeLib/Menu/SongMenu/CSong.cs b/VocaluxeLib/Menu/SongMenu/CSong.cs index 1d4fb03d..37d73066 100644 --- a/VocaluxeLib/Menu/SongMenu/CSong.cs +++ b/VocaluxeLib/Menu/SongMenu/CSong.cs @@ -230,9 +230,7 @@ namespace VocaluxeLib.Menu.SongMenu public static CSong LoadSong(string filePath) { CSong song = new CSong(); - if (song.ReadHeader(filePath)) - return song; - return null; + return song.ReadHeader(filePath) ? song : null; } public CSong(CSong song) @@ -785,11 +783,19 @@ namespace VocaluxeLib.Menu.SongMenu return false; } sr.Dispose(); - _FindRefrain(); - _FindShortEnd(); - _NotesLoaded = true; - if (IsDuet) - _CheckDuet(); + try + { + _FindRefrain(); + _FindShortEnd(); + _NotesLoaded = true; + if (IsDuet) + _CheckDuet(); + } + catch (Exception e) + { + CBase.Log.LogError("Error loading song. An unhandled exception occured (" + e.Message + "): " + filePath); + return false; + } return true; }