Remove running scripts before loading session

Clean up scripts instead of just clearing script list
This commit is contained in:
kalimag 2022-11-27 19:54:00 +01:00 committed by James Groom
parent cc10de4033
commit 28d6415190
1 changed files with 11 additions and 0 deletions

View File

@ -354,6 +354,14 @@ namespace BizHawk.Client.EmuHawk
LuaImp.ScriptList.Remove(item);
}
private void RemoveAllLuaFiles()
{
while (LuaImp.ScriptList.Count > 0)
{
RemoveLuaFile(LuaImp.ScriptList[LuaImp.ScriptList.Count - 1]);
}
}
private void UpdateDialog()
{
LuaListView.RowCount = LuaImp.ScriptList.Count;
@ -489,6 +497,8 @@ namespace BizHawk.Client.EmuHawk
public bool LoadLuaSession(string path)
{
RemoveAllLuaFiles();
var result = LuaImp.ScriptList.Load(path, Settings.DisableLuaScriptsOnLoad);
foreach (var script in LuaImp.ScriptList)
@ -743,6 +753,7 @@ namespace BizHawk.Client.EmuHawk
if (result)
{
RemoveAllLuaFiles();
LuaImp.ScriptList.Clear();
ClearOutputWindow();
UpdateDialog();