From 5d07cff19f59efd722d7c835cd81e5973e90c447 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 6 Jan 2015 16:35:22 +0000 Subject: [PATCH] Tastuduio - issue 359 - fix issues with Asking to save changes on close combined with threaded saving, not the prettiest work around but it should work --- .../tools/TAStudio/TAStudio.IToolForm.cs | 1 + .../tools/TAStudio/TAStudio.MenuItems.cs | 21 +++++++++++++++++-- .../tools/TAStudio/TAStudio.cs | 14 +++++++++---- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs index ac648befe5..63e3086e71 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.IToolForm.cs @@ -102,6 +102,7 @@ namespace BizHawk.Client.EmuHawk GlobalWin.Sound.StartSound(); if (result == DialogResult.Yes) { + _exiting = true; // Asking to save changes should only ever be called when closing something SaveTasMenuItem_Click(null, null); } else if (result == DialogResult.No) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs index 9ceae16fb0..6beaeb615e 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.MenuItems.cs @@ -68,6 +68,8 @@ namespace BizHawk.Client.EmuHawk } } + private bool _exiting = false; + private void SaveTasMenuItem_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(CurrentTasMovie.Filename) || @@ -77,7 +79,14 @@ namespace BizHawk.Client.EmuHawk } else { - _saveBackgroundWorker.RunWorkerAsync(); + if (_exiting) + { + CurrentTasMovie.Save(); + } + else + { + _saveBackgroundWorker.RunWorkerAsync(); + } Settings.RecentTas.Add(CurrentTasMovie.Filename); } } @@ -95,7 +104,15 @@ namespace BizHawk.Client.EmuHawk { CurrentTasMovie.Filename = file.FullName; - _saveBackgroundWorker.RunWorkerAsync(); + if (_exiting) + { + CurrentTasMovie.Save(); + } + else + { + _saveBackgroundWorker.RunWorkerAsync(); + } + Settings.RecentTas.Add(CurrentTasMovie.Filename); SetTextProperty(); } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs index 6f6b37b2b0..91e48c6d2f 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.cs @@ -230,10 +230,14 @@ namespace BizHawk.Client.EmuHawk text += " - " + CurrentTasMovie.Name + (CurrentTasMovie.Changes ? "*" : ""); } - if (this.InvokeRequired) - this.Invoke(() => Text = text); - else - Text = text; + if (this.InvokeRequired) + { + this.Invoke(() => Text = text); + } + else + { + Text = text; + } } public bool LoadProject(string path) @@ -631,6 +635,7 @@ namespace BizHawk.Client.EmuHawk private void Tastudio_Closing(object sender, FormClosingEventArgs e) { + _exiting = true; if (AskSaveChanges()) { WantsToControlStopMovie = false; @@ -640,6 +645,7 @@ namespace BizHawk.Client.EmuHawk else { e.Cancel = true; + _exiting = false; } }