From 819dfc434ff03138ec40b524a286cd8731c8bfe9 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 27 Jan 2016 12:44:23 +1100 Subject: [PATCH] Fix 'classicalsharp has crashed' dialog being shown multiple times in the launcher. --- Launcher2/LauncherWindow.cs | 1 + Launcher2/Program.cs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Launcher2/LauncherWindow.cs b/Launcher2/LauncherWindow.cs index f21188c48..4cd0798fd 100644 --- a/Launcher2/LauncherWindow.cs +++ b/Launcher2/LauncherWindow.cs @@ -70,6 +70,7 @@ namespace Launcher2 { } void FocusedChanged( object sender, EventArgs e ) { + if( Program.ShowingErrorDialog ) return; MakeBackground(); Screen.Resize(); } diff --git a/Launcher2/Program.cs b/Launcher2/Program.cs index fc0168074..d6b4c1d4f 100644 --- a/Launcher2/Program.cs +++ b/Launcher2/Program.cs @@ -10,13 +10,20 @@ namespace Launcher2 { public static string AppDirectory; + public static bool ShowingErrorDialog = false; + [STAThread] static void Main( string[] args ) { AppDirectory = AppDomain.CurrentDomain.BaseDirectory; string logPath = Path.Combine( AppDirectory, "launcher.log" ); + AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler; ErrorHandler.InstallHandler( logPath ); LauncherWindow window = new LauncherWindow(); window.Run(); } + + static void UnhandledExceptionHandler( object sender, UnhandledExceptionEventArgs e ) { + ShowingErrorDialog = true; + } } }