lua-fix crashes when scripts terminate
This commit is contained in:
parent
ec9cf60d6d
commit
3a8fe7c464
|
@ -218,15 +218,25 @@ namespace BizHawk.MultiClient
|
|||
public class ResumeResult
|
||||
{
|
||||
public bool WaitForFrame;
|
||||
public bool Terminated;
|
||||
}
|
||||
|
||||
public ResumeResult ResumeScript(Lua script)
|
||||
{
|
||||
currThread = script;
|
||||
script.Resume(0);
|
||||
int execResult = script.Resume(0);
|
||||
currThread = null;
|
||||
var result = new ResumeResult();
|
||||
result.WaitForFrame = FrameAdvanceRequested;
|
||||
if (execResult == 0)
|
||||
{
|
||||
//terminated
|
||||
result.Terminated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//yielded
|
||||
result.WaitForFrame = FrameAdvanceRequested;
|
||||
}
|
||||
FrameAdvanceRequested = false;
|
||||
return result;
|
||||
}
|
||||
|
|
Binary file not shown.
|
@ -845,6 +845,7 @@ namespace BizHawk.MultiClient
|
|||
if (!prohibit)
|
||||
{
|
||||
var result = LuaImp.ResumeScript(s.Thread);
|
||||
if(result.Terminated) s.Stop();
|
||||
s.FrameWaiting = result.WaitForFrame;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -527,8 +527,8 @@ namespace LuaInterface
|
|||
int ret = LuaDLL.lua_resume(luaState, narg);
|
||||
if (ret == 1 /*LUA_YIELD*/)
|
||||
return 1; //yielded
|
||||
if (ret == 0) //normal termination - what to do?
|
||||
return 0;
|
||||
if (ret == 0)
|
||||
return 0; //normal termination
|
||||
//error. throw exception with error message (TBD - debug api to get call stack)
|
||||
ThrowExceptionFromError(top);
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue