From 04bee5f950048975ca2573add27a2ad51fb55068 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Fri, 25 Feb 2011 02:45:22 +0000 Subject: [PATCH] Fix crash on saving config if ram watch is closed. Refactor some config saving stuff --- BizHawk.MultiClient/MainForm.cs | 34 +++++++++++-------- .../tools/RamWatch.Designer.cs | 2 -- BizHawk.MultiClient/tools/RamWatch.cs | 27 +++++---------- 3 files changed, 28 insertions(+), 35 deletions(-) diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index e34fad7298..313a57702a 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -75,19 +75,8 @@ namespace BizHawk.MultiClient Closing += (o, e) => { - CloseGame(); - if (Global.Config.SaveWindowPosition) - { - Global.Config.MainWndx = this.Location.X; - Global.Config.MainWndy = this.Location.Y; - } - else - { - Global.Config.MainWndx = -1; - Global.Config.MainWndy = -1; - } - RamWatch1.SaveConfigSettings(); - ConfigService.Save("config.ini", Global.Config); + CloseGame(); + SaveConfig(); }; ResizeBegin += (o, e) => @@ -1068,7 +1057,7 @@ namespace BizHawk.MultiClient private void saveConfigToolStripMenuItem_Click(object sender, EventArgs e) { - ConfigService.Save("config.ini", Global.Config); + SaveConfig(); Global.RenderPanel.AddMessage("Saved settings"); } @@ -1078,6 +1067,21 @@ namespace BizHawk.MultiClient Global.RenderPanel.AddMessage("Saved loaded"); } - + private void SaveConfig() + { + if (Global.Config.SaveWindowPosition) + { + Global.Config.MainWndx = this.Location.X; + Global.Config.MainWndy = this.Location.Y; + } + else + { + Global.Config.MainWndx = -1; + Global.Config.MainWndy = -1; + } + if (!RamWatch1.IsDisposed) + RamWatch1.SaveConfigSettings(); + ConfigService.Save("config.ini", Global.Config); + } } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/RamWatch.Designer.cs b/BizHawk.MultiClient/tools/RamWatch.Designer.cs index b6a6b248f8..ffe52d0680 100644 --- a/BizHawk.MultiClient/tools/RamWatch.Designer.cs +++ b/BizHawk.MultiClient/tools/RamWatch.Designer.cs @@ -671,8 +671,6 @@ this.Load += new System.EventHandler(this.RamWatch_Load); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.RamWatch_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.RamWatch_DragEnter); - this.Resize += new System.EventHandler(this.RamWatch_Resize); - this.LocationChanged += new System.EventHandler(this.RamWatch_LocationChanged); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.contextMenuStrip1.ResumeLayout(false); diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index 52717e71b0..913a2147f5 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -91,7 +91,10 @@ namespace BizHawk.MultiClient Global.Config.RamWatchChangeWidth = WatchListView.Columns[3].Width; Global.Config.RamWatchNotesWidth = WatchListView.Columns[4].Width; - + Global.Config.RamWatchWndx = this.Location.X; + Global.Config.RamWatchWndy = this.Location.Y; + Global.Config.RamWatchWidth = this.Right - this.Left; + Global.Config.RamWatchHeight = this.Bottom - this.Top; } public RamWatch() @@ -726,32 +729,20 @@ namespace BizHawk.MultiClient } } - private void RamWatch_LocationChanged(object sender, EventArgs e) - { - Global.Config.RamWatchWndx = this.Location.X; - Global.Config.RamWatchWndy = this.Location.Y; - } - - private void RamWatch_Resize(object sender, EventArgs e) - { - Global.Config.RamWatchWidth = this.Right - this.Left; - Global.Config.RamWatchHeight = this.Bottom - this.Top; - } - private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e) { this.Size = new System.Drawing.Size(defaultWidth, defaultHeight); - WatchListView.Columns[0].Width = Global.Config.RamWatchAddressWidth; - WatchListView.Columns[1].Width = Global.Config.RamWatchValueWidth; + WatchListView.Columns[0].Width = 59; //Address + WatchListView.Columns[1].Width = 59; //Value if (showPreviousValueToolStripMenuItem.Checked) - WatchListView.Columns[2].Width = Global.Config.RamWatchPrevWidth; + WatchListView.Columns[2].Width = 59; //Prev else WatchListView.Columns[2].Width = 0; if (showChangeCountsToolStripMenuItem.Checked) - WatchListView.Columns[3].Width = Global.Config.RamWatchChangeWidth; + WatchListView.Columns[3].Width = 54; //Change counts else WatchListView.Columns[3].Width = 0; - WatchListView.Columns[4].Width = Global.Config.RamWatchNotesWidth; + WatchListView.Columns[4].Width = 130; //Notes } private void newToolStripButton_Click(object sender, EventArgs e)