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.
This commit is contained in:
Niels Martin Hansen 2009-05-24 23:19:28 +00:00
parent c8768d8043
commit a1a4d797e7
1 changed files with 9 additions and 1 deletions

View File

@ -274,7 +274,15 @@ void HotkeyManager::Load() {
using namespace std; using namespace std;
TextFileReader file(filename); TextFileReader file(filename);
wxString header = file.ReadLineFromFile(); 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 // Get variables
wxString curLine; wxString curLine;