From c4d95421e0c28d4ed27a7651090bf303b42be48e Mon Sep 17 00:00:00 2001 From: baldurk Date: Sun, 4 Oct 2015 15:31:10 +0200 Subject: [PATCH] Fix crash if main window is closed while update check is ongoing --- renderdocui/Windows/MainWindow.cs | 36 +++++++++++++++++++------------ 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/renderdocui/Windows/MainWindow.cs b/renderdocui/Windows/MainWindow.cs index 1910293a1..f1e145107 100644 --- a/renderdocui/Windows/MainWindow.cs +++ b/renderdocui/Windows/MainWindow.cs @@ -1065,13 +1065,17 @@ namespace renderdocui.Windows if (response != "") { - BeginInvoke((MethodInvoker)delegate + // window may have been closed while update check was on-going. If so, just return + if (Visible) { - m_Core.Config.CheckUpdate_UpdateAvailable = true; - m_Core.Config.CheckUpdate_UpdateResponse = response; - SetUpdateAvailable(); - UpdatePopup(); - }); + BeginInvoke((MethodInvoker)delegate + { + m_Core.Config.CheckUpdate_UpdateAvailable = true; + m_Core.Config.CheckUpdate_UpdateResponse = response; + SetUpdateAvailable(); + UpdatePopup(); + }); + } result = UpdateResult.Upgrade; } else if (callback != null) @@ -1092,15 +1096,19 @@ namespace renderdocui.Windows // and it's not worth trying to retry. } - BeginInvoke((MethodInvoker)delegate + // window may have been closed while update check was on-going. If so, just return + if (Visible) { - statusText.Text = ""; - statusProgress.Visible = false; - statusProgress.Style = ProgressBarStyle.Continuous; - statusProgress.MarqueeAnimationSpeed = 0; - if (callback != null && result != UpdateResult.Disabled) - callback(result); - }); + BeginInvoke((MethodInvoker)delegate + { + statusText.Text = ""; + statusProgress.Visible = false; + statusProgress.Style = ProgressBarStyle.Continuous; + statusProgress.MarqueeAnimationSpeed = 0; + if (callback != null && result != UpdateResult.Disabled) + callback(result); + }); + } })); updateThread.Start();