Avoid Crashing After Trying To Delete A Script With Errors.
This commit is contained in:
parent
35f42b94f3
commit
5283b4c06c
|
@ -114,6 +114,7 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
public Lua SpawnCoroutine(string File)
|
public Lua SpawnCoroutine(string File)
|
||||||
{
|
{
|
||||||
|
LuaConsole Luas = new LuaConsole();
|
||||||
var t = lua.NewThread();
|
var t = lua.NewThread();
|
||||||
LuaRegister(t);
|
LuaRegister(t);
|
||||||
var main = t.LoadFile(File);
|
var main = t.LoadFile(File);
|
||||||
|
|
|
@ -240,8 +240,10 @@ namespace BizHawk.MultiClient
|
||||||
for (int x = 0; x < indexes.Count; x++)
|
for (int x = 0; x < indexes.Count; x++)
|
||||||
{
|
{
|
||||||
var item = luaList[indexes[x]];
|
var item = luaList[indexes[x]];
|
||||||
if(!item.IsSeparator)
|
if (!item.IsSeparator)
|
||||||
item.Toggle();
|
{
|
||||||
|
item.Toggle();
|
||||||
|
}
|
||||||
if (item.Enabled && item.Thread == null)
|
if (item.Enabled && item.Thread == null)
|
||||||
item.Thread = LuaImp.SpawnCoroutine(item.Path);
|
item.Thread = LuaImp.SpawnCoroutine(item.Path);
|
||||||
else if (!item.Enabled && item.Thread != null)
|
else if (!item.Enabled && item.Thread != null)
|
||||||
|
@ -253,7 +255,7 @@ namespace BizHawk.MultiClient
|
||||||
changes = true;
|
changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RunLuaScripts()
|
public void RunLuaScripts()
|
||||||
{
|
{
|
||||||
for (int x = 0; x < luaList.Count; x++)
|
for (int x = 0; x < luaList.Count; x++)
|
||||||
{
|
{
|
||||||
|
@ -384,15 +386,15 @@ namespace BizHawk.MultiClient
|
||||||
if (luaList.Count == 0) return;
|
if (luaList.Count == 0) return;
|
||||||
changes = true;
|
changes = true;
|
||||||
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
|
ListView.SelectedIndexCollection indexes = LuaListView.SelectedIndices;
|
||||||
if (indexes.Count > 0)
|
if (indexes.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (int index in indexes)
|
foreach (int index in indexes)
|
||||||
{
|
{
|
||||||
luaList.Remove(luaList[indexes[0]]); //index[0] used since each iteration will make this the correct list index
|
luaList.Remove(luaList[indexes[0]]); //index[0] used since each iteration will make this the correct list index
|
||||||
}
|
}
|
||||||
indexes.Clear();
|
indexes.Clear();
|
||||||
DisplayLuaList();
|
DisplayLuaList();
|
||||||
}
|
}
|
||||||
UpdateNumberOfScripts();
|
UpdateNumberOfScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +668,6 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
private void cutToolStripButton_Click(object sender, EventArgs e)
|
private void cutToolStripButton_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Toggle();
|
|
||||||
RemoveScript();
|
RemoveScript();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -780,16 +781,23 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
foreach (var s in luaList)
|
foreach (var s in luaList)
|
||||||
{
|
{
|
||||||
if (s.Enabled && s.Thread != null && !s.Paused)
|
try
|
||||||
{
|
{
|
||||||
bool prohibit = false;
|
if (s.Enabled && s.Thread != null && !s.Paused)
|
||||||
if (s.FrameWaiting && !includeFrameWaiters)
|
{
|
||||||
prohibit = true;
|
bool prohibit = false;
|
||||||
|
if (s.FrameWaiting && !includeFrameWaiters)
|
||||||
|
prohibit = true;
|
||||||
|
|
||||||
if (prohibit) continue;
|
if (prohibit) continue;
|
||||||
var result = LuaImp.ResumeScript(s.Thread);
|
var result = LuaImp.ResumeScript(s.Thread);
|
||||||
s.FrameWaiting = result.WaitForFrame;
|
s.FrameWaiting = result.WaitForFrame;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
MessageBox.Show("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue