From c8e82ba1e53012a068fcc5e1ca7662fb11d07785 Mon Sep 17 00:00:00 2001 From: Morilli <35152647+Morilli@users.noreply.github.com> Date: Mon, 5 May 2025 20:31:06 +0200 Subject: [PATCH] dispose discs in dosbox see #4301 --- .../Computers/DOS/DOSBox.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs b/src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs index 8d2b973000..bf235ce33b 100644 --- a/src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs +++ b/src/BizHawk.Emulation.Cores/Computers/DOS/DOSBox.cs @@ -45,6 +45,7 @@ namespace BizHawk.Emulation.Cores.Computers.DOS private int _floppyDiskCount = 0; private int _currentFloppyDisk = 0; private int _currentCDROM = 0; + private bool _disposed; private string GetFullName(IRomAsset rom) => Path.GetFileName(rom.RomPath.SubstringAfter('|')); @@ -606,5 +607,21 @@ namespace BizHawk.Emulation.Cores.Computers.DOS _libDOSBox.GetHDDData(hddArray); return hddArray; } + + public override void Dispose() + { + if (_disposed) return; + _disposed = true; + + if (_discAssets is not null) + { + foreach (var discAsset in _discAssets) + { + discAsset.DiscData.Dispose(); + } + } + + base.Dispose(); + } } }