Lua - fix #691 - When calling client.reboot_core we still want to re-inject dependencies to the lua libraries

This commit is contained in:
adelikat 2016-08-28 12:07:26 -04:00
parent 2b0dc82d16
commit 11b4f5a5b1
3 changed files with 16 additions and 5 deletions

View File

@ -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; }

View File

@ -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();

View File

@ -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();
}