From 5ab9bce321d324cb20659b6e3d236093760bacc7 Mon Sep 17 00:00:00 2001 From: maj00r Date: Mon, 16 Nov 2026 00:01:46 +0100 Subject: [PATCH] fix(settings): a profile is not moved to physicslog.trains, and a closed tape window keeps nothing - the one-time move runs on the player's own settings only; a profile from before it keeps physicslog as it was, and the player's mark of the move stays when it is applied - a read of the tapes under way when the window closes is let go --- StarterNG.Tests/SettingsStoreTests.cs | 17 +++++++++++++++++ StarterNG/Application/SettingsStore.cs | 11 +++++++++-- StarterNG/Views/Tapes/HaslerTapeWindow.cs | 10 ++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/StarterNG.Tests/SettingsStoreTests.cs b/StarterNG.Tests/SettingsStoreTests.cs index 5edc3e8..b712520 100644 --- a/StarterNG.Tests/SettingsStoreTests.cs +++ b/StarterNG.Tests/SettingsStoreTests.cs @@ -1257,6 +1257,23 @@ public class SettingsStoreTests Assert.False(store.LoadFailed); } + [Fact] + public void A_profile_from_before_the_move_is_not_moved_and_keeps_the_players_mark() + { + var files = new InMemoryFileSystem() + .WithFile(UserIni, "starter.physicslog.moved yes\nphysicslog yes\n") + .WithFile(Profile, "physicslog yes\n"); + var store = WithHome(files).SettingsStore; + store.Load(); + + Assert.True(store.TryLoadProfile(Profile)); + store.Save(); + + Assert.True(store.Settings.PhysicsLog); + Assert.False(store.Settings.PhysicsLogTrains); + Assert.Contains("starter.physicslog.moved yes", files.ReadAllText(UserIni, System.Text.Encoding.UTF8)); + } + [Fact] public void A_missing_profile_leaves_the_settings_as_they_are() { diff --git a/StarterNG/Application/SettingsStore.cs b/StarterNG/Application/SettingsStore.cs index a185609..8e39473 100644 --- a/StarterNG/Application/SettingsStore.cs +++ b/StarterNG/Application/SettingsStore.cs @@ -83,6 +83,9 @@ public sealed class SettingsStore string source = _files.FileExists(_savePath) ? _savePath : _paths.InstallationConfigPath(); LoadedFrom = source; LoadFrom(source); + // the player's own settings only, after the snapshot so the next save writes it; a profile is not moved + if (!LoadFailed) + SettingsSerializer.MovePhysicsLog(Settings); } /// A player with no settings of their own yet starts at High, in the file at once so the simulator goes by it too. @@ -113,8 +116,6 @@ public sealed class SettingsStore _serializer.Read(Settings, _config); _synced = Render(Settings); - if (!LoadFailed) - SettingsSerializer.MovePhysicsLog(Settings); TouchConfigAge(); } @@ -126,9 +127,15 @@ public sealed class SettingsStore { if (_files.FileExists(path)) { + // a profile saved before the move has no mark of it: the player's mark is kept, so their own + // physicslog is not moved again at the next start + bool moved = Settings.PhysicsLogMoved; LoadFrom(path); if (!LoadFailed) + { + Settings.PhysicsLogMoved |= moved; return true; + } } if (LoadFailed) diff --git a/StarterNG/Views/Tapes/HaslerTapeWindow.cs b/StarterNG/Views/Tapes/HaslerTapeWindow.cs index 9cc1e3b..7283026 100644 --- a/StarterNG/Views/Tapes/HaslerTapeWindow.cs +++ b/StarterNG/Views/Tapes/HaslerTapeWindow.cs @@ -73,6 +73,8 @@ public sealed class HaslerTapeWindow : Window private bool _running; private bool _loading; private bool _looking; + // closed: a read already under way when it closed is let go, not kept followed + private bool _closed; /// A setting went on from here; the settings page's boxes have to follow it. public event Action? LogEnabled; @@ -226,6 +228,7 @@ public sealed class HaslerTapeWindow : Window Activated += (_, _) => ShowWhatIsKnown(); Closed += (_, _) => { + _closed = true; _timer.Stop(); _tapes.Forget(); }; @@ -643,6 +646,11 @@ public sealed class HaslerTapeWindow : Window // the same tape grown, as the simulator writes it: only what was added is read bool follow = file.Path == _shown?.Path && file.Size >= _shown.Size; var tape = await Task.Run(() => _tapes.Load(file, follow)); + if (_closed) + { + _tapes.Forget(); + return; + } bool another = file.Path != _shown?.Path; _shown = file; _tapeless = null; @@ -697,6 +705,8 @@ public sealed class HaslerTapeWindow : Window try { var sessions = await Task.Run(_tapes.Sessions); + if (_closed) + return; bool live = _live.IsChecked == true; bool newDriven = live && DrivenTape(sessions) is { } driven && driven.Path != _followed; if (newDriven || Fingerprint(sessions) != _listed)