fix a crash when loading a quicksave right after shutting down retroachievements

This commit is contained in:
CasualPokePlayer 2023-01-25 22:43:57 -08:00
parent f8a5adecb5
commit 03077daf71
2 changed files with 20 additions and 14 deletions

View File

@ -133,6 +133,7 @@ namespace BizHawk.Client.EmuHawk
{
RA?.Shutdown();
_memGuard.Dispose();
_mainForm.EmuClient.BeforeQuickLoad -= QuickLoadCallback;
}
public override void OnSaveState(string path)
@ -147,6 +148,14 @@ namespace BizHawk.Client.EmuHawk
RA.OnLoadState(path);
}
private static void QuickLoadCallback(object _, BeforeQuickLoadEventArgs e)
{
if (RA.HardcoreModeIsActive())
{
e.Handled = !RA.WarnDisableHardcore("load a quicksave");
}
}
public override void Stop()
{
@ -214,13 +223,7 @@ namespace BizHawk.Client.EmuHawk
_mainForm.UpdateWindowTitle();
// note: this can only catch quicksaves (probably only case of accidential use from hotkeys)
_mainForm.EmuClient.BeforeQuickLoad += (_, e) =>
{
if (RA.HardcoreModeIsActive())
{
e.Handled = !RA.WarnDisableHardcore("load a quicksave");
}
};
_mainForm.EmuClient.BeforeQuickLoad += QuickLoadCallback;
}
public override void Update()

View File

@ -213,6 +213,7 @@ namespace BizHawk.Client.EmuHawk
_gameInfoForm.Dispose();
_cheevoListForm.Dispose();
_lboardListForm.Dispose();
_mainForm.EmuClient.BeforeQuickLoad -= QuickLoadCallback;
}
public override void OnSaveState(string path)
@ -252,6 +253,14 @@ namespace BizHawk.Client.EmuHawk
var buffer = file.ReadAllBytes();
_lib.rc_runtime_deserialize_progress(ref _runtime, buffer, IntPtr.Zero);
}
private void QuickLoadCallback(object _, BeforeQuickLoadEventArgs e)
{
if (HardcoreMode)
{
e.Handled = _mainForm.ShowMessageBox2(null, "Loading a quicksave is not allowed in hardcode mode. Abort loading state?", "Warning", EMsgBoxIcon.Warning);
}
}
// not sure if we really need to do anything here...
// nice way to ensure config is written back every so often (and on close)
@ -385,13 +394,7 @@ namespace BizHawk.Client.EmuHawk
Update();
// note: this can only catch quicksaves (probably only case of accidential use from hotkeys)
_mainForm.EmuClient.BeforeQuickLoad += (_, e) =>
{
if (HardcoreMode)
{
e.Handled = _mainForm.ShowMessageBox2(null, "Loading a quicksave is not allowed in hardcode mode. Abort loading state?", "Warning", EMsgBoxIcon.Warning);
}
};
_mainForm.EmuClient.BeforeQuickLoad += QuickLoadCallback;
}
public override void Update()