Fix the actual Win7 launch crash (issue #22): empty send-mode list
The real cause — from the tester's crash stack, not my earlier (wrong)
System.ServiceProcess theory: ApplySendModeVisibility() is called early in the
MainForm constructor (via ApplyAsioMode), BEFORE the Input/Output tab populates
the send-mode ListBox. On Windows 7 process-loopback is unsupported, so it took
the `!supported` branch and set SelectedIndex on an EMPTY list, throwing
ArgumentOutOfRangeException ("value ('0') must be less than '0'") and crashing
at launch. On Windows 10/11 that branch is skipped (process-loopback IS
supported), which hid it from the gate and from every Win10/11 test.
.NET 10 genuinely runs on the tester's Win7 SP1 box (CoreLib 10.0.826 in the
crash) — so the earlier assembly-load theory was wrong; those Win7 changes were
addressing a non-problem. This is the fault.
Fix: guard the SelectedIndex set with `sendModeList.Items.Count > 0`. When the
list is empty there's nothing to reset (it's created selecting Devices, and this
runs again once the tab is built).
Test: "Main window builds where process-loopback is unsupported (issue #22)" —
forces ProcessLoopbackCapture.IsSupported = false (new ForceSupportedForTest
seam) and constructs the headless MainForm, so a Win10/11 box exercises the Win7
path. VERIFIED it reproduces: with the guard reverted the test fails with the
exact tester exception; with the guard it passes. Gate 34/34.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
0567ea22c3
commit
c482857314
@@ -3621,7 +3621,13 @@ public sealed class MainForm : Form
|
||||
// The chooser row only makes sense where applications mode is possible.
|
||||
if (sendModeLabel is not null) sendModeLabel.Visible = supported;
|
||||
SetRowControlVisible(sendModeList, supported);
|
||||
if (!supported && sendModeList.SelectedIndex != SendModeDevicesIndex)
|
||||
// Items.Count > 0 guard: this method is called once EARLY in the constructor (via ApplyAsioMode)
|
||||
// before the Input/Output tab has populated sendModeList, so the list can still be empty here.
|
||||
// Setting SelectedIndex on an empty ListBox throws ArgumentOutOfRangeException. On Windows 10+ the
|
||||
// branch is skipped anyway (process-loopback IS supported), which hid the bug — but on Windows 7
|
||||
// (unsupported) it crashed the app at launch (issue #22). When the list is empty there's nothing to
|
||||
// reset; it's created selecting Devices, and this runs again (line ~3611) once the list is built.
|
||||
if (!supported && sendModeList.Items.Count > 0 && sendModeList.SelectedIndex != SendModeDevicesIndex)
|
||||
{
|
||||
suppressSendAppEvents = true;
|
||||
sendModeList.SelectedIndex = SendModeDevicesIndex;
|
||||
|
||||
Reference in New Issue
Block a user