From af93cf3e9265ad955d709c6af895233bef10adfa Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 10 Jun 2020 09:15:52 -0500 Subject: [PATCH] consolidate logic that instantiates a new rewinder, be sure to dispose the old one --- src/BizHawk.Client.EmuHawk/MainForm.cs | 31 ++++++++++--------- .../config/RewindConfig.cs | 3 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index 20f9f97e5d..4cbbd81611 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -11,7 +11,6 @@ using System.Windows.Forms; using BizHawk.Common; using BizHawk.Common.BufferExtensions; -using BizHawk.Common.IOExtensions; using BizHawk.Client.Common; using BizHawk.Bizware.BizwareGL; @@ -304,8 +303,6 @@ namespace BizHawk.Client.EmuHawk UpdateStatusSlots(); UpdateKeyPriorityIcon(); - - try { _argParser.ParseArguments(args); @@ -883,7 +880,17 @@ namespace BizHawk.Client.EmuHawk private Sound Sound => GlobalWin.Sound; public CheatCollection CheatList => GlobalWin.CheatList; - public IRewinder Rewinder { get; set; } + public IRewinder Rewinder { get; private set; } + + public void CreateRewinder() + { + Rewinder?.Dispose(); + + if (Emulator.HasSavestates()) + { + Rewinder = new Rewinder(Emulator.AsStatable(), Config.Rewind); + } + } private FirmwareManager FirmwareManager => GlobalWin.FirmwareManager; @@ -3806,16 +3813,7 @@ namespace BizHawk.Client.EmuHawk CurrentlyOpenRomArgs = args; OnRomChanged(); DisplayManager.Blank(); - - if (Emulator.HasSavestates()) - { - Rewinder = new Rewinder(Emulator.AsStatable(), Config.Rewind); - } - else - { - Rewinder?.Dispose(); - Rewinder = null; - } + CreateRewinder(); GlobalWin.InputManager.StickyXorAdapter.ClearStickies(); GlobalWin.InputManager.StickyXorAdapter.ClearStickyAxes(); @@ -4001,7 +3999,10 @@ namespace BizHawk.Client.EmuHawk return; } - Rewinder ??= new Rewinder(Emulator.AsStatable(), Config.Rewind); + if (Rewinder == null) + { + CreateRewinder(); + } if (enabled) { diff --git a/src/BizHawk.Client.EmuHawk/config/RewindConfig.cs b/src/BizHawk.Client.EmuHawk/config/RewindConfig.cs index 8aec6c9399..be4338a903 100644 --- a/src/BizHawk.Client.EmuHawk/config/RewindConfig.cs +++ b/src/BizHawk.Client.EmuHawk/config/RewindConfig.cs @@ -185,8 +185,7 @@ namespace BizHawk.Client.EmuHawk if (TriggerRewindSettingsReload) { - _mainForm.Rewinder.Dispose(); - _mainForm.Rewinder = new Rewinder(_statableCore, _config.Rewind); + _mainForm.CreateRewinder(); } DialogResult = DialogResult.OK;