diff --git a/src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs b/src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs index 44918de435b..16874a88182 100644 --- a/src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs +++ b/src/DynamoCoreWpf/Views/SplashScreen/SplashScreen.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; @@ -37,6 +38,9 @@ public partial class SplashScreen : Window // Timer used for Splash Screen loading internal Stopwatch loadingTimer; + // Indicates if the SplashScren close button has already been hit. + private bool closeCalled; + /// /// Total loading time for the Dynamo loading tasks in milliseconds /// @@ -156,6 +160,19 @@ public SplashScreen(bool enableSignInButton = true) this.enableSignInButton = enableSignInButton; } + protected override void OnClosing(CancelEventArgs e) + { + if (!closeCalled) + { + closeCalled = true; + + // In case the splash screen's close button is hit multiple times, + // so we need to call the Window.Closing event only one time. + // (if we call this multiple times, webview2.IsVisible setter can be called after webview2.Dispose resulting in a crash) + base.OnClosing(e); + } + } + private void DynamoModel_LanguageDetected() { SetLabels();