Fixed crash with faulty song files

This commit is contained in:
Flamefire committed 2013-04-16 16:47:38 +02:00
1 parent 71251b8733
commit 55849376ba
1 file changed
+9 -3
+9 -3
View File
@@ -230,9 +230,7 @@ namespace VocaluxeLib.Menu.SongMenu
public static CSong LoadSong(string filePath) public static CSong LoadSong(string filePath)
{ {
CSong song = new CSong(); CSong song = new CSong();
if (song.ReadHeader(filePath)) return song.ReadHeader(filePath) ? song : null;
return song;
return null;
} }
public CSong(CSong song) public CSong(CSong song)
@@ -785,11 +783,19 @@ namespace VocaluxeLib.Menu.SongMenu
return false; return false;
} }
sr.Dispose(); sr.Dispose();
try
{
_FindRefrain(); _FindRefrain();
_FindShortEnd(); _FindShortEnd();
_NotesLoaded = true; _NotesLoaded = true;
if (IsDuet) if (IsDuet)
_CheckDuet(); _CheckDuet();
}
catch (Exception e)
{
CBase.Log.LogError("Error loading song. An unhandled exception occured (" + e.Message + "): " + filePath);
return false;
}
return true; return true;
} }