From 6e72e47c1c0b1f69b7c5d07c4275e9eaade32f96 Mon Sep 17 00:00:00 2001 From: zeromus Date: Thu, 22 Mar 2018 14:55:29 -0500 Subject: [PATCH] do a thing better than crash when configfiles are corrupt. fixes #1063 --- BizHawk.Client.EmuHawk/Program.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs index a6a5e5a538..47d97f0f1b 100644 --- a/BizHawk.Client.EmuHawk/Program.cs +++ b/BizHawk.Client.EmuHawk/Program.cs @@ -121,8 +121,19 @@ namespace BizHawk.Client.EmuHawk HawkFile.ArchiveHandlerFactory = new SevenZipSharpArchiveHandler(); string iniPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini"); - Global.Config = ConfigService.Load(iniPath); + + try + { + Global.Config = ConfigService.Load(iniPath); + } catch (Exception e) { + new ExceptionBox(e).ShowDialog(); + new ExceptionBox("Since your config file is corrupted, we're going to recreate it. Back it up before proceeding if you want to investigate further.").ShowDialog(); + File.Delete(iniPath); + Global.Config = ConfigService.Load(iniPath); + } + Global.Config.ResolveDefaults(); + BizHawk.Client.Common.StringLogUtil.DefaultToDisk = Global.Config.MoviesOnDisk; BizHawk.Client.Common.StringLogUtil.DefaultToAWE = Global.Config.MoviesInAWE;