Skip to content

Commit

Permalink
Merge pull request #465 from eksime/dev
Browse files Browse the repository at this point in the history
Fix NullReferenceException on gw2 process exit
  • Loading branch information
dlamkins authored Sep 23, 2021
2 parents fd2ff6b + d19a8b9 commit 56b09ba
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Blish HUD/GameServices/GameIntegration/Gw2InstanceIntegration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -178,15 +179,14 @@ private void HandleProcessUpdate(Process newProcess) {
} catch (NullReferenceException e) {
Logger.Warn(e, "Failed to grab Guild Wars 2 env variable. It is likely exiting.");
}
}

// 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<bool> e) {
Expand Down

0 comments on commit 56b09ba

Please sign in to comment.