From 29a9d1fcf18766726581b47f90576c4489dbe30c Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Sun, 24 May 2009 23:19:28 +0000 Subject: [PATCH] Turn broken hotkeys.dat file into a non-fatal error. If the file is broken (usually meaning exists but empty) the existing file will now be copied to hotkeys.bak and the defaults restored and saved as hotkeys.dat. Originally committed to SVN as r2982. --- aegisub/src/hotkeys.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/aegisub/src/hotkeys.cpp b/aegisub/src/hotkeys.cpp index e00dd2762..26eeae6b8 100644 --- a/aegisub/src/hotkeys.cpp +++ b/aegisub/src/hotkeys.cpp @@ -274,7 +274,15 @@ void HotkeyManager::Load() { using namespace std; TextFileReader file(filename); wxString header = file.ReadLineFromFile(); - if (header != _T("[Hotkeys]")) throw _T("Invalid hotkeys file"); + if (header != _T("[Hotkeys]")) { + wxFileName backupfn(filename); + backupfn.SetFullName(_T("hotkeys.bak")); + wxCopyFile(filename, backupfn.GetFullPath()); + modified = true; + Save(); + wxLogWarning(_T("Hotkeys file corrupted, defaults restored.\nA backup of the corrupted file was made.")); + return; + } // Get variables wxString curLine;