From 60b9825f64eb0f2631da848efe7dadacf8c0e873 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 15 Jul 2017 22:09:50 -0500 Subject: [PATCH] fix race condition in test of active window from input thread (which was a bad idea in the first place) which can throw null references in unlucky cases (fixes #917) --- BizHawk.Client.EmuHawk/Input/Input.cs | 1 + BizHawk.Client.EmuHawk/MainForm.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/BizHawk.Client.EmuHawk/Input/Input.cs b/BizHawk.Client.EmuHawk/Input/Input.cs index 67c88793aa..cc8d2fa6a8 100644 --- a/BizHawk.Client.EmuHawk/Input/Input.cs +++ b/BizHawk.Client.EmuHawk/Input/Input.cs @@ -414,6 +414,7 @@ namespace BizHawk.Client.EmuHawk } + //WHAT!? WE SHOULD NOT BE SO NAIVELY TOUCHING MAINFORM FROM THE INPUTTHREAD. ITS BUSY RUNNING. bool swallow = !GlobalWin.MainForm.AllowInput(false); foreach (var ie in _NewEvents) diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs index eb34dd6e2a..9965c31309 100644 --- a/BizHawk.Client.EmuHawk/MainForm.cs +++ b/BizHawk.Client.EmuHawk/MainForm.cs @@ -643,15 +643,15 @@ namespace BizHawk.Client.EmuHawk // even more special logic for TAStudio: // TODO - implement by event filter in TAStudio - if (ActiveForm is TAStudio) + var maybeTAStudio = ActiveForm as TAStudio; + if (maybeTAStudio != null) { if (yieldAlt) { return false; } - var ts = (TAStudio)ActiveForm; - if (ts.IsInMenuLoop) + if (maybeTAStudio.IsInMenuLoop) { return false; }