Don't dispose hawkfile stream after ReadAllBytes(), fix ReadAllBytes callsites to do disposal properly
This commit is contained in:
parent
4aa334244e
commit
a30c0efb78
|
@ -835,7 +835,7 @@ namespace BizHawk.Client.Common
|
|||
var ext = file.Extension;
|
||||
var gi = Disc.IsValidExtension(ext)
|
||||
? MakeGameFromDisc(InstantiateDiscFor(path), ext: ext, name: Path.GetFileNameWithoutExtension(file.Name))
|
||||
: new RomGame(new(file.CanonicalFullPath)).GameInfo; // need to re-open???
|
||||
: new RomGame(file).GameInfo;
|
||||
Game.Name = $"{gi.Name} [{Game.Name/* core name */}]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
using var rom = new HawkFile(result);
|
||||
if (rom.IsArchive) rom.BindFirst();
|
||||
var romData = (ReadOnlySpan<byte>) rom.ReadAllBytes();
|
||||
var romData = new ReadOnlySpan<byte>(rom.ReadAllBytes());
|
||||
int headerBytes = romData.Length % 1024; // assume that all roms have sizes divisible by 1024, and any rest is header
|
||||
romData = romData[headerBytes..];
|
||||
if (matchesMovieHash(romData))
|
||||
|
|
|
@ -478,7 +478,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
// to always be copied to the global firmware directory
|
||||
if (hf.IsArchive)
|
||||
{
|
||||
var ac = new ArchiveChooser(new HawkFile(filePath));
|
||||
using var ac = new ArchiveChooser(hf);
|
||||
if (!ac.ShowDialog(this).IsOk()) return;
|
||||
|
||||
var insideFile = hf.BindArchiveMember(ac.SelectedMemberIndex);
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
if (PalettePath.Text.Length > 0)
|
||||
{
|
||||
var palette = new HawkFile(PalettePath.Text);
|
||||
using var palette = new HawkFile(PalettePath.Text);
|
||||
|
||||
if (palette.Exists)
|
||||
{
|
||||
|
|
|
@ -87,7 +87,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
filter: FilesystemFilterSet.Palettes,
|
||||
initDir: _config.PathEntries.PalettesAbsolutePathFor(VSystemID.Raw.NES));
|
||||
if (result is null) return;
|
||||
HawkFile palette = new(result);
|
||||
using HawkFile palette = new(result);
|
||||
|
||||
if (palette.Exists)
|
||||
{
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
return;
|
||||
}
|
||||
|
||||
using ArchiveChooser ac = new(new(hawkPath)); //TODO can we pass hf here instead of instantiating a new HawkFile?
|
||||
using ArchiveChooser ac = new(hf);
|
||||
if (!this.ShowDialogAsChild(ac).IsOk()
|
||||
|| ac.SelectedMemberIndex < 0 || hf.ArchiveItems.Count <= ac.SelectedMemberIndex)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue