From d19a8b9a0d6cab095944b5b6c4888e91cd5f0b4e Mon Sep 17 00:00:00 2001 From: Elliot Sime Date: Thu, 23 Sep 2021 19:04:38 +0100 Subject: [PATCH] Fix NullReferenceException on process exit in Gw2InstanceIntegration::HandleProcessUpdate when getting the window class name when newProcess is null --- .../GameIntegration/Gw2InstanceIntegration.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Blish HUD/GameServices/GameIntegration/Gw2InstanceIntegration.cs b/Blish HUD/GameServices/GameIntegration/Gw2InstanceIntegration.cs index 67777e259..ced3dad40 100644 --- a/Blish HUD/GameServices/GameIntegration/Gw2InstanceIntegration.cs +++ b/Blish HUD/GameServices/GameIntegration/Gw2InstanceIntegration.cs @@ -164,6 +164,7 @@ private void HandleProcessUpdate(Process newProcess) { BlishHud.Instance.Form.Invoke((MethodInvoker)(() => { BlishHud.Instance.Form.Visible = false; })); _gw2Process = null; + this.Gw2IsRunning = false; } else { if (_gw2Process.MainModule != null) { _gw2ExecutablePath.Value = _gw2Process.MainModule.FileName; @@ -174,15 +175,14 @@ private void HandleProcessUpdate(Process newProcess) { if (envs.ContainsKey(APPDATA_ENVKEY)) { this.AppDataPath = envs[APPDATA_ENVKEY]; } - } - // GW2 is running if the "_gw2Process" isn't null and the class name of process' - // window is the game window name (so we know we are passed the login screen) - string windowClass = WindowUtil.GetClassNameOfWindow(this.Gw2Process.MainWindowHandle); + // GW2 is running if the "_gw2Process" isn't null and the class name of process' + // window is the game window name (so we know we are passed the login screen) + string windowClass = WindowUtil.GetClassNameOfWindow(_gw2Process.MainWindowHandle); - this.Gw2IsRunning = _gw2Process != null - && windowClass == ApplicationSettings.Instance.WindowName - || windowClass != GW2_PATCHWINDOW_CLASS; + this.Gw2IsRunning = windowClass == ApplicationSettings.Instance.WindowName + || windowClass != GW2_PATCHWINDOW_CLASS; + } } private void OnGameFocusChanged(object sender, ValueEventArgs e) {