From 2c6129fb683e94daf1098502a93ce66ca0932c3b Mon Sep 17 00:00:00 2001 From: kalimag Date: Wed, 5 Jun 2024 02:00:55 +0200 Subject: [PATCH] Fix possible TAStudio NRE (squashed PR #3936) * Skip `AskSaveChanges` in disposed `TAStudio`, fix #3499 * Revert "Skip `AskSaveChanges` in disposed `TAStudio`, fix #3499" This reverts commit eabe939547bf3d377d841e73edbd92249acdccbb. * Stop calling `AskSaveChanges()` on inactive tools, fix #3499 --- src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.cs | 2 +- src/BizHawk.Client.EmuHawk/tools/ToolManager.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.cs b/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.cs index 3823a2d81b7..f59904b2f1d 100644 --- a/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.cs +++ b/src/BizHawk.Client.EmuHawk/tools/Macros/MacroInput.cs @@ -97,7 +97,7 @@ public override void Restart() public override bool AskSaveChanges() { - if (_unsavedZones.Count == 0 || IsDisposed) + if (_unsavedZones.Count == 0) { return true; } diff --git a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs index a0b1d494986..028e77953e7 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -616,9 +616,7 @@ public bool AskSave() return true; } - return _tools - .Select(tool => tool.AskSaveChanges()) - .All(result => result); + return _tools.TrueForAll(tool => !tool.IsActive || tool.AskSaveChanges()); } ///