fix lua's reboot_core function... maybe

This commit is contained in:
zeromus 2015-12-19 21:14:00 -06:00
parent 250bc38a56
commit 260ad45a88
4 changed files with 12 additions and 1 deletions

View File

@ -312,7 +312,10 @@ namespace BizHawk.Client.EmuHawk
)]
public static void RebootCore()
{
//pretty hacky.. we dont want a lua script to be able to restart itself by rebooting the core
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).IsRebootingCore = true;
GlobalWin.MainForm.RebootCore();
((LuaConsole)GlobalWin.Tools.Get<LuaConsole>()).IsRebootingCore = false;
}
[LuaMethodAttributes(

View File

@ -144,7 +144,8 @@ namespace BizHawk.Client.EmuHawk
public Lua SpawnCoroutine(string file)
{
var lua = _lua.NewThread();
var main = lua.LoadString(File.ReadAllText(file), "main");
var content = File.ReadAllText(file);
var main = lua.LoadString(content, "main");
lua.Push(main); // push main function on to stack for subsequent resuming
return lua;
}

View File

@ -27,6 +27,8 @@ namespace BizHawk.Client.EmuHawk
private List<string> _consoleCommandHistory = new List<string>();
private int _consoleCommandHistoryIndex = -1;
public bool IsRebootingCore;
public LuaConsole()
{
_sortReverse = false;

View File

@ -441,7 +441,12 @@ 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();
}