From 5667081764889ab984e122cbf207bd29e04652d5 Mon Sep 17 00:00:00 2001 From: teinarss Date: Wed, 14 Apr 2021 19:10:49 +0200 Subject: [PATCH] Fix log should be disposed correctly --- OpenRA.Launcher/Program.cs | 25 ++++++++++++++----------- OpenRA.WindowsLauncher/Program.cs | 4 ++++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/OpenRA.Launcher/Program.cs b/OpenRA.Launcher/Program.cs index fd26346c8b..46d2e795ca 100644 --- a/OpenRA.Launcher/Program.cs +++ b/OpenRA.Launcher/Program.cs @@ -20,19 +20,22 @@ namespace OpenRA.Launcher [STAThread] static int Main(string[] args) { - if (Debugger.IsAttached || args.Contains("--just-die")) - return (int)Game.InitializeAndRun(args); - - AppDomain.CurrentDomain.UnhandledException += (_, e) => ExceptionHandler.HandleFatalError((Exception)e.ExceptionObject); - try { - return (int)Game.InitializeAndRun(args); - } - catch (Exception e) - { - ExceptionHandler.HandleFatalError(e); - return (int)RunStatus.Error; + if (Debugger.IsAttached || args.Contains("--just-die")) + return (int)Game.InitializeAndRun(args); + + AppDomain.CurrentDomain.UnhandledException += (_, e) => ExceptionHandler.HandleFatalError((Exception)e.ExceptionObject); + + try + { + return (int)Game.InitializeAndRun(args); + } + catch (Exception e) + { + ExceptionHandler.HandleFatalError(e); + return (int)RunStatus.Error; + } } finally { diff --git a/OpenRA.WindowsLauncher/Program.cs b/OpenRA.WindowsLauncher/Program.cs index ae1a98a144..f593733d9b 100644 --- a/OpenRA.WindowsLauncher/Program.cs +++ b/OpenRA.WindowsLauncher/Program.cs @@ -78,6 +78,10 @@ namespace OpenRA.WindowsLauncher ExceptionHandler.HandleFatalError(e); return (int)RunStatus.Error; } + finally + { + Log.Dispose(); + } } static int RunInnerLauncher(string[] args)