From 11b4f5a5b10413d4e4a153d3a2ad7ae67c9ff23c Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 28 Aug 2016 12:07:26 -0400 Subject: [PATCH] Lua - fix #691 - When calling client.reboot_core we still want to re-inject dependencies to the lua libraries --- .../tools/Lua/Libraries/EmuLuaLibrary.cs | 8 ++++++++ BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs | 7 +++++++ BizHawk.Client.EmuHawk/tools/ToolManager.cs | 6 +----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs index e23924fc39..b28f720227 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs @@ -94,6 +94,14 @@ namespace BizHawk.Client.EmuHawk EmulatorLuaLibrary.YieldCallback = EmuYield; } + public void Restart() + { + foreach (var lib in Libraries) + { + ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, lib.Value); + } + } + public LuaDocumentation Docs { get; private set; } public bool IsRunning { get; set; } public EventWaitHandle LuaWait { get; private set; } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index ac8482ffff..c5471b4e7e 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -135,6 +135,13 @@ namespace BizHawk.Client.EmuHawk public void Restart() { + // Even if the lua console is self-rebooting from client.reboot_core() we still want to re-inject dependencies + if (IsRebootingCore) + { + LuaImp.Restart(); + return; + } + if (LuaImp != null && LuaImp.GuiLibrary != null && LuaImp.GuiLibrary.HasLuaSurface) { LuaImp.GuiLibrary.DrawFinish(); diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index fc7de1142c..6749e2d55c 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -456,12 +456,8 @@ namespace BizHawk.Client.EmuHawk if (ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, tool.GetType())) { ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, tool); - bool restartTool = false; + if ((tool.IsHandleCreated && !tool.IsDisposed) || tool is RamWatch) // Hack for RAM Watch - in display watches mode it wants to keep running even closed, it will handle disposed logic - restartTool = true; - if (tool is LuaConsole && ((LuaConsole)tool).IsRebootingCore) - restartTool = false; - if (restartTool) { tool.Restart(); }