Lua - fix memory leaks
This commit is contained in:
parent
03e4403b9c
commit
f8a962294a
|
@ -840,39 +840,42 @@ namespace BizHawk.MultiClient
|
||||||
/// <param name="includeFrameWaiters">should frame waiters be waken up? only use this immediately before a frame of emulation</param>
|
/// <param name="includeFrameWaiters">should frame waiters be waken up? only use this immediately before a frame of emulation</param>
|
||||||
public void ResumeScripts(bool includeFrameWaiters)
|
public void ResumeScripts(bool includeFrameWaiters)
|
||||||
{
|
{
|
||||||
if (LuaImp.luaSurface == null)
|
if (luaList != null && luaList.Count > 0)
|
||||||
{
|
{
|
||||||
LuaImp.gui_drawNewEmu();
|
if (LuaImp.luaSurface == null)
|
||||||
}
|
|
||||||
for (int i = 0; i < luaList.Count; i++)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
//LuaImp.gui_clearGraphics();
|
LuaImp.gui_drawNewEmu();
|
||||||
if (luaList[i].Enabled && luaList[i].Thread != null && !(luaList[i].Paused))
|
|
||||||
{
|
|
||||||
bool prohibit = false;
|
|
||||||
if (luaList[i].FrameWaiting && !includeFrameWaiters)
|
|
||||||
{
|
|
||||||
prohibit = true;
|
|
||||||
}
|
|
||||||
if (!prohibit)
|
|
||||||
{
|
|
||||||
var result = LuaImp.ResumeScript(luaList[i].Thread);
|
|
||||||
if (result.Terminated) luaList[i].Stop();
|
|
||||||
luaList[i].FrameWaiting = result.WaitForFrame;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
for (int i = 0; i < luaList.Count; i++)
|
||||||
{
|
{
|
||||||
if (ex is LuaInterface.LuaScriptException || ex is LuaInterface.LuaException)
|
try
|
||||||
{
|
{
|
||||||
luaList[i].Enabled = false;
|
//LuaImp.gui_clearGraphics();
|
||||||
luaList[i].Thread = null;
|
if (luaList[i].Enabled && luaList[i].Thread != null && !(luaList[i].Paused))
|
||||||
AddText(ex.ToString());
|
{
|
||||||
|
bool prohibit = false;
|
||||||
|
if (luaList[i].FrameWaiting && !includeFrameWaiters)
|
||||||
|
{
|
||||||
|
prohibit = true;
|
||||||
|
}
|
||||||
|
if (!prohibit)
|
||||||
|
{
|
||||||
|
var result = LuaImp.ResumeScript(luaList[i].Thread);
|
||||||
|
if (result.Terminated) luaList[i].Stop();
|
||||||
|
luaList[i].FrameWaiting = result.WaitForFrame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
if (ex is LuaInterface.LuaScriptException || ex is LuaInterface.LuaException)
|
||||||
|
{
|
||||||
|
luaList[i].Enabled = false;
|
||||||
|
luaList[i].Thread = null;
|
||||||
|
AddText(ex.ToString());
|
||||||
|
}
|
||||||
|
else MessageBox.Show(ex.ToString());
|
||||||
}
|
}
|
||||||
else MessageBox.Show(ex.ToString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//LuaImp.gui_drawFinishEmu();
|
//LuaImp.gui_drawFinishEmu();
|
||||||
|
@ -880,12 +883,18 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
public void StartLuaDrawing()
|
public void StartLuaDrawing()
|
||||||
{
|
{
|
||||||
LuaImp.gui_drawNewEmu();
|
if (luaList != null && luaList.Count > 0)
|
||||||
|
{
|
||||||
|
LuaImp.gui_drawNewEmu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndLuaDrawing()
|
public void EndLuaDrawing()
|
||||||
{
|
{
|
||||||
LuaImp.gui_drawFinishEmu();
|
if (luaList != null && luaList.Count > 0)
|
||||||
|
{
|
||||||
|
LuaImp.gui_drawFinishEmu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRunning()
|
public bool IsRunning()
|
||||||
|
|
Loading…
Reference in New Issue