Fix the crash on changing network settings, and apply resynced contacts in batches

ApplyNetworkSettings disposed the station link without clearing it, so
ApplyStationLinkSettings disposed it a second time and threw. Only the
second function touches the link now, and StationLink.Dispose can be
called twice.

Contacts from the network are queued and applied together on the window
thread. Each one used to rescore the whole log and redraw the log window,
which kept the window thread busy for minutes during a resync.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-24 00:26:03 +00:00
co-authored by Claude Sonnet 5.5
parent 0e5aa3238b
commit 085584a281
5 changed files with 134 additions and 28 deletions
+29 -1
View File
@@ -131,10 +131,10 @@ public sealed class ContestSession
foreach (Qso qso in gone)
{
store.Delete(qso.Id);
Log.Remove(qso.Id);
}
if (gone.Count > 0)
{
Log.RemoveRange([.. gone.Select(q => q.Id)]);
Changed?.Invoke(this, EventArgs.Empty);
}
return gone.Count;
@@ -208,6 +208,34 @@ public sealed class ContestSession
return true;
}
/// `AddFromNetwork` for a burst of contacts, which is what a resync sends.
/// The log is scored and `Changed` is raised once for the lot, because
/// doing either per contact keeps the window thread busy for minutes on a
/// log of a few thousand. Returns how many were new.
public int AddRangeFromNetwork(IEnumerable<Qso> arriving)
{
HashSet<string> held = [.. Log.Qsos.Select(q => q.Id)];
List<Qso> stored = [];
foreach (Qso qso in arriving)
{
if (held.Add(qso.Id))
{
stored.Add(store.Add(FromNetwork(qso)));
}
}
if (stored.Count == 0)
{
return 0;
}
Log.InsertRange(stored);
foreach (Qso qso in stored)
{
RecordNumber(qso);
}
Changed?.Invoke(this, EventArgs.Empty);
return stored.Count;
}
/// An edit made at another station. False when we do not hold the contact
/// it changes.
public bool ReplaceFromNetwork(Qso qso, string oldCall, DateTime oldTimestampUtc)