diff --git a/src/BizHawk.Client.Common/FileWriter.cs b/src/BizHawk.Client.Common/FileWriter.cs
index 039c8f4769..a6e019b9e0 100644
--- a/src/BizHawk.Client.Common/FileWriter.cs
+++ b/src/BizHawk.Client.Common/FileWriter.cs
@@ -167,8 +167,7 @@ namespace BizHawk.Client.Common
if (_dispoed) return;
_dispoed = true;
- _stream!.Flush(flushToDisk: true);
- _stream.Dispose();
+ _stream!.Dispose();
_stream = null;
// The caller should call CloseAndDispose and handle potential failure.
diff --git a/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs b/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs
index 3a2649872b..1e5268bf1d 100644
--- a/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs
+++ b/src/BizHawk.Client.EmuHawk/IMainFormForTools.cs
@@ -20,9 +20,6 @@ namespace BizHawk.Client.EmuHawk
// TODO: remove? or does anything ever need access to the FirmwareManager
FirmwareManager FirmwareManager { get; }
- /// only referenced from
- bool GameIsClosing { get; }
-
/// only referenced from
bool HoldFrameAdvance { get; set; }
diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs
index a0eedda0b9..6972a519c9 100644
--- a/src/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/src/BizHawk.Client.EmuHawk/MainForm.cs
@@ -885,7 +885,7 @@ namespace BizHawk.Client.EmuHawk
return;
}
}
- // zero 03-nov-2015 - close game after other steps. tools might need to unhook themselves from a core.
+
CloseGame();
SaveConfig();
}
@@ -3795,10 +3795,6 @@ namespace BizHawk.Client.EmuHawk
loader.OnLoadSettings += CoreSettings;
loader.OnLoadSyncSettings += CoreSyncSettings;
- // this also happens in CloseGame(). But it needs to happen here since if we're restarting with the same core,
- // any settings changes that we made need to make it back to config before we try to instantiate that core with
- // the new settings objects
- CommitCoreSettingsToConfig(); // adelikat: I Think by reordering things, this isn't necessary anymore
CloseGame();
var nextComm = CreateCoreComm();
@@ -4085,13 +4081,12 @@ namespace BizHawk.Client.EmuHawk
}
}
- // whats the difference between these two methods??
- // its very tricky. rename to be more clear or combine them.
- // This gets called whenever a core related thing is changed.
- // Like reboot core.
+ ///
+ /// This closes the game but does not set things up for using the client with the new null emulator.
+ /// This method should only be called (outside of ) if the caller is about to load a new game with no user interaction between close and load.
+ ///
private void CloseGame(bool clearSram = false)
{
- GameIsClosing = true;
if (clearSram)
{
var path = Config.PathEntries.SaveRamAbsolutePath(Game, MovieSession.Movie);
@@ -4138,7 +4133,7 @@ namespace BizHawk.Client.EmuHawk
CommitCoreSettingsToConfig();
DisableRewind();
- if (MovieSession.Movie.IsActive()) // Note: this must be called after CommitCoreSettingsToConfig()
+ if (MovieSession.Movie.IsActive()) // Note: this must be called after CommitCoreSettingsToConfig() because it checks if we have an active movie.
{
StopMovie();
}
@@ -4152,7 +4147,6 @@ namespace BizHawk.Client.EmuHawk
InputManager.SyncControls(Emulator, MovieSession, Config);
RewireSound();
RebootStatusBarIcon.Visible = false;
- GameIsClosing = false;
}
private FileWriteResult AutoSaveStateIfConfigured()
@@ -4165,12 +4159,12 @@ namespace BizHawk.Client.EmuHawk
return new();
}
- public bool GameIsClosing { get; private set; } // Lets tools make better decisions when being called by CloseGame
-
+ ///
+ /// This closes the current ROM, closes tools that require emulator services, and sets things up for the user to interact with the client having no loaded ROM.
+ ///
+ /// True if SRAM should be deleted instead of saved.
public void CloseRom(bool clearSram = false)
{
- // This gets called after Close Game gets called.
- // Tested with NESHawk and SMB3 (U)
if (Tools.AskSave())
{
CloseGame(clearSram);
diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs
index 272afddc2b..d19e0bb1a7 100644
--- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs
+++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IControlMainForm.cs
@@ -59,13 +59,10 @@
public void StopMovie(bool suppressSave)
{
- if (!MainForm.GameIsClosing)
- {
- Activate();
- _suppressAskSave = suppressSave;
- StartNewTasMovie();
- _suppressAskSave = false;
- }
+ Activate();
+ _suppressAskSave = suppressSave;
+ StartNewTasMovie();
+ _suppressAskSave = false;
}
public bool WantsToControlRewind { get; private set; } = true;