From f75142213bf9c3959a91aa578902331b77af3f18 Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 3 Jun 2014 03:09:43 +0000 Subject: [PATCH] make lua surface clearing more robust --- .../DisplayManager/DisplayManager.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs index c940a4867e..330695f772 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs @@ -524,6 +524,16 @@ TESTEROO: SwappableDisplaySurfaceSet luaNativeSurfaceSet = new SwappableDisplaySurfaceSet(); public void SetLuaSurfaceNativePreOSD(DisplaySurface surface) { luaNativeSurfaceSet.SetPending(surface); } + /// + /// Peeks a locked lua surface, or returns null if it isnt locked + /// + public DisplaySurface PeekLockedLuaSurface(string name) + { + if (MapNameToLuaSurface.ContainsKey(name)) + return MapNameToLuaSurface[name]; + return null; + } + /// /// Locks the requested lua surface name /// @@ -558,9 +568,13 @@ TESTEROO: { foreach (var kvp in LuaSurfaceSets) { - var surf = LockLuaSurface(kvp.Key); + var surf = PeekLockedLuaSurface(kvp.Key); + DisplaySurface surfLocked = null; + if (surf == null) + surf = surfLocked = LockLuaSurface(kvp.Key); surf.Clear(); - UnlockLuaSurface(surf); + if(surfLocked != null) + UnlockLuaSurface(surfLocked); LuaSurfaceSets[kvp.Key].SetPending(null); } }