From 2859d6c45b5f6878d64c9f1f7807f85cbbf16846 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Wed, 24 Feb 2021 10:41:28 +1000 Subject: [PATCH] Inline the autolock hack and use it for both surfaces --- .../Api/Classes/GuiApi.cs | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/BizHawk.Client.Common/Api/Classes/GuiApi.cs b/src/BizHawk.Client.Common/Api/Classes/GuiApi.cs index ef8e6558b5..89e3532e2b 100644 --- a/src/BizHawk.Client.Common/Api/Classes/GuiApi.cs +++ b/src/BizHawk.Client.Common/Api/Classes/GuiApi.cs @@ -83,12 +83,26 @@ namespace BizHawk.Client.Common private DisplaySurface GetRelevantSurface(DisplaySurfaceID? surfaceID) { - switch (surfaceID ?? _usingSurfaceID) + var nnID = surfaceID ?? _usingSurfaceID ?? throw new Exception(); + void ThisIsTheLuaAutolockHack() + { + try + { + UnlockSurface(nnID); + LockSurface(nnID); + } + catch (InvalidOperationException ex) + { + LogCallback(ex.ToString()); + } + } + switch (nnID) { case DisplaySurfaceID.EmuCore: - if (_GUISurface == null && EnableLuaAutolockHack) LockEmuSurfaceLua(); + if (_GUISurface == null && EnableLuaAutolockHack) ThisIsTheLuaAutolockHack(); return _GUISurface; case DisplaySurfaceID.Client: + if (_clientSurface == null && EnableLuaAutolockHack) ThisIsTheLuaAutolockHack(); return _clientSurface; default: throw new Exception(); @@ -144,19 +158,6 @@ namespace BizHawk.Client.Common } } - public void LockEmuSurfaceLua() - { - try - { - UnlockSurface(DisplaySurfaceID.EmuCore); - LockSurface(DisplaySurfaceID.EmuCore); - } - catch (InvalidOperationException ex) - { - LogCallback(ex.ToString()); - } - } - public void UnlockEmuSurfaceLua() => UnlockSurface(DisplaySurfaceID.EmuCore); public void DrawNew(string name, bool clear)