Avoid Crashing After Trying To Delete A Script With Errors.

This commit is contained in:
rolanmen1 2012-03-25 15:34:09 +00:00
parent 35f42b94f3
commit 5283b4c06c
2 changed files with 31 additions and 22 deletions

View File

@ -114,6 +114,7 @@ namespace BizHawk.MultiClient
public Lua SpawnCoroutine(string File)
{
LuaConsole Luas = new LuaConsole();
var t = lua.NewThread();
LuaRegister(t);
var main = t.LoadFile(File);

View File

@ -240,8 +240,10 @@ namespace BizHawk.MultiClient
for (int x = 0; x < indexes.Count; x++)
{
var item = luaList[indexes[x]];
if(!item.IsSeparator)
item.Toggle();
if (!item.IsSeparator)
{
item.Toggle();
}
if (item.Enabled && item.Thread == null)
item.Thread = LuaImp.SpawnCoroutine(item.Path);
else if (!item.Enabled && item.Thread != null)
@ -253,7 +255,7 @@ namespace BizHawk.MultiClient
changes = true;
}
private void RunLuaScripts()
public void RunLuaScripts()
{
for (int x = 0; x < luaList.Count; x++)
{
@ -384,15 +386,15 @@ namespace BizHawk.MultiClient
if (luaList.Count == 0) return;
changes = true;
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
if (indexes.Count > 0)
{
foreach (int index in indexes)
{
luaList.Remove(luaList[indexes[0]]); //index[0] used since each iteration will make this the correct list index
}
indexes.Clear();
DisplayLuaList();
}
if (indexes.Count > 0)
{
foreach (int index in indexes)
{
luaList.Remove(luaList[indexes[0]]); //index[0] used since each iteration will make this the correct list index
}
indexes.Clear();
DisplayLuaList();
}
UpdateNumberOfScripts();
}
@ -666,7 +668,6 @@ namespace BizHawk.MultiClient
private void cutToolStripButton_Click(object sender, EventArgs e)
{
Toggle();
RemoveScript();
}
@ -780,16 +781,23 @@ namespace BizHawk.MultiClient
{
foreach (var s in luaList)
{
if (s.Enabled && s.Thread != null && !s.Paused)
{
bool prohibit = false;
if (s.FrameWaiting && !includeFrameWaiters)
prohibit = true;
try
{
if (s.Enabled && s.Thread != null && !s.Paused)
{
bool prohibit = false;
if (s.FrameWaiting && !includeFrameWaiters)
prohibit = true;
if (prohibit) continue;
var result = LuaImp.ResumeScript(s.Thread);
s.FrameWaiting = result.WaitForFrame;
}
if (prohibit) continue;
var result = LuaImp.ResumeScript(s.Thread);
s.FrameWaiting = result.WaitForFrame;
}
}
catch
{
MessageBox.Show("");
}
}
}