diff --git a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs index 6072b8c1b7..855dc7e148 100644 --- a/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs +++ b/BizHawk.Client.EmuHawk/DisplayManager/DisplayManager.cs @@ -711,14 +711,21 @@ TESTEROO: { foreach (var kvp in LuaSurfaceSets) { - var surf = PeekLockedLuaSurface(kvp.Key); - DisplaySurface surfLocked = null; - if (surf == null) - surf = surfLocked = LockLuaSurface(kvp.Key); - surf.Clear(); - if(surfLocked != null) - UnlockLuaSurface(surfLocked); - LuaSurfaceSets[kvp.Key].SetPending(null); + try + { + var surf = PeekLockedLuaSurface(kvp.Key); + DisplaySurface surfLocked = null; + if (surf == null) + surf = surfLocked = LockLuaSurface(kvp.Key); + surf.Clear(); + if (surfLocked != null) + UnlockLuaSurface(surfLocked); + LuaSurfaceSets[kvp.Key].SetPending(null); + } + catch (InvalidOperationException) + { + + } } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs index 998f0c4481..ec414856c7 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Gui.cs @@ -52,8 +52,15 @@ namespace BizHawk.Client.EmuHawk )] public void DrawNew(string name) { - DrawFinish(); - _luaSurface = GlobalWin.DisplayManager.LockLuaSurface(name); + try + { + DrawFinish(); + _luaSurface = GlobalWin.DisplayManager.LockLuaSurface(name); + } + catch (InvalidOperationException ex) + { + Log(ex.ToString()); + } } public void DrawFinish()