Maybe fix mutation of IEnumerable (`InvalidOperationException`)

fixes 3024bc0d0
This commit is contained in:
YoshiRulz 2022-09-29 05:21:08 +10:00
parent f0529fde28
commit 7a26546cfc
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 6 additions and 5 deletions

View File

@ -186,7 +186,7 @@ namespace BizHawk.Client.EmuHawk
{ {
try try
{ {
foreach (var lf in RegisteredFunctions.Where(l => l.Event == "OnSavestateSave")) foreach (var lf in RegisteredFunctions.Where(static l => l.Event == "OnSavestateSave").ToList())
{ {
lf.Call(name); lf.Call(name);
} }
@ -203,7 +203,7 @@ namespace BizHawk.Client.EmuHawk
{ {
try try
{ {
foreach (var lf in RegisteredFunctions.Where(l => l.Event == "OnSavestateLoad")) foreach (var lf in RegisteredFunctions.Where(static l => l.Event == "OnSavestateLoad").ToList())
{ {
lf.Call(name); lf.Call(name);
} }
@ -221,7 +221,7 @@ namespace BizHawk.Client.EmuHawk
if (IsUpdateSupressed) return; if (IsUpdateSupressed) return;
try try
{ {
foreach (var lf in RegisteredFunctions.Where(l => l.Event == "OnFrameStart")) foreach (var lf in RegisteredFunctions.Where(static l => l.Event == "OnFrameStart").ToList())
{ {
lf.Call(); lf.Call();
} }
@ -239,7 +239,7 @@ namespace BizHawk.Client.EmuHawk
if (IsUpdateSupressed) return; if (IsUpdateSupressed) return;
try try
{ {
foreach (var lf in RegisteredFunctions.Where(l => l.Event == "OnFrameEnd")) foreach (var lf in RegisteredFunctions.Where(static l => l.Event == "OnFrameEnd").ToList())
{ {
lf.Call(); lf.Call();
} }
@ -255,7 +255,8 @@ namespace BizHawk.Client.EmuHawk
public void CallExitEvent(LuaFile lf) public void CallExitEvent(LuaFile lf)
{ {
foreach (var exitCallback in RegisteredFunctions foreach (var exitCallback in RegisteredFunctions
.Where(l => l.Event == "OnExit" && (l.LuaFile.Path == lf.Path || l.LuaFile.Thread == lf.Thread))) .Where(l => l.Event == "OnExit" && (l.LuaFile.Path == lf.Path || l.LuaFile.Thread == lf.Thread))
.ToList())
{ {
exitCallback.Call(); exitCallback.Call();
} }