From 7fea5f8543271a3187912216f00a20a71e8d4f19 Mon Sep 17 00:00:00 2001 From: zeromus Date: Sat, 13 Sep 2014 20:37:14 +0000 Subject: [PATCH] fix problems with stale memorydomains in hex editor. fixes issue #262 --- BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 3f6f8d5b8c..fbaafad222 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -59,7 +59,7 @@ namespace BizHawk.Client.EmuHawk private bool _bigEndian; private int _dataSize; - private readonly MemoryDomainList MemoryDomains; + private MemoryDomainList MemoryDomains; public HexEditor() { @@ -67,7 +67,6 @@ namespace BizHawk.Client.EmuHawk fontWidth = (int)font.Size; fontHeight = font.Height + 1; - MemoryDomains = ((IMemoryDomains)Global.Emulator).MemoryDomains; // The cast is intentional, we want a specific cast error, not an eventual null reference error InitializeComponent(); AddressesLabel.BackColor = Color.Transparent; LoadConfigSettings(); @@ -79,6 +78,8 @@ namespace BizHawk.Client.EmuHawk AddressLabel.Font = font; TopMost = Global.Config.HexEditorSettings.TopMost; + + Restart(); } private int? HighlightedAddress @@ -132,16 +133,21 @@ namespace BizHawk.Client.EmuHawk public void Restart() { + MemoryDomains = null; + if (!Global.Emulator.HasMemoryDomains()) { Close(); } + if (!IsHandleCreated || IsDisposed) { return; } + MemoryDomains = ((IMemoryDomains)Global.Emulator).MemoryDomains; // The cast is intentional, we want a specific cast error, not an eventual null reference error + var theDomain = _domain.Name.ToLower() == "file on disk" ? 999 : GetDomainInt(_domain.Name); SetMemoryDomainMenu(); // Calls update routines, TODO: refactor, that is confusing! @@ -456,6 +462,8 @@ namespace BizHawk.Client.EmuHawk private void HexEditor_Load(object sender, EventArgs e) { + Restart(); + _defaultWidth = Size.Width; // Save these first so that the user can restore to its original size _defaultHeight = Size.Height;