Fix logic that news up new Rewinders, properly dispose of the Rewinder on closeRom, this might fix memory leaks in rewinder that pre-date the recent refactor

This commit is contained in:
adelikat 2020-06-10 15:06:34 -05:00
parent af93cf3e92
commit 73e2922a0d
2 changed files with 6 additions and 6 deletions

View File

@ -385,7 +385,9 @@ namespace BizHawk.Client.EmuHawk
private void CloseRomMenuItem_Click(object sender, EventArgs e)
{
Console.WriteLine($"Closing rom clicked Frame: {Emulator.Frame} Emulator: {Emulator.GetType().Name}");
CloseRom();
Console.WriteLine($"Closing rom clicked DONE Frame: {Emulator.Frame} Emulator: {Emulator.GetType().Name}");
}
private void Savestate1MenuItem_Click(object sender, EventArgs e) { SaveQuickSave("QuickSave1"); }

View File

@ -885,11 +885,9 @@ namespace BizHawk.Client.EmuHawk
public void CreateRewinder()
{
Rewinder?.Dispose();
if (Emulator.HasSavestates())
{
Rewinder = new Rewinder(Emulator.AsStatable(), Config.Rewind);
}
Rewinder = Emulator.HasSavestates()
? new Rewinder(Emulator.AsStatable(), Config.Rewind)
: null;
}
private FirmwareManager FirmwareManager => GlobalWin.FirmwareManager;
@ -3957,7 +3955,7 @@ namespace BizHawk.Client.EmuHawk
CloseGame(clearSram);
Emulator = new NullEmulator();
GlobalWin.Game = GameInfo.NullInstance;
CreateRewinder();
Tools.Restart(Emulator);
RewireSound();
ClearHolds();