fix(launcher): Campaign LA — MainWindow must call InitializeComponent, not AvaloniaXamlLoader.Load

Every click in the launcher exited the process. MainWindow ctor called
AvaloniaXamlLoader.Load(this), which loads the XAML tree but never assigns
the generated x:Name backing fields, so ProfilesTree, ServerNameTextBox,
AccountNameTextBox, CharacterNameTextBox, EditorSubmitButton,
FirstRunDatDirectoryTextBox and UpdateCloseButton were all null. Opening or
closing any modal calls Focus() on one of them via
OnViewModelPropertyChanged, so the NullReferenceException escaped the
dispatcher and Program's top-level guard exited 74. A fresh isolated-root
start auto-opens the first-run wizard and hit the same line with no click
at all.

App.axaml.cs keeps AvaloniaXamlLoader.Load - that is the correct idiom for
Application.Initialize(), which has no named controls.

Verified live: the isolated-root launch that died instantly now stays up
with the first-run wizard open and the window responding.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-15 07:31:34 +02:00
parent c25545e8d6
commit d54b8a789e

View file

@ -18,7 +18,13 @@ public sealed partial class MainWindow : Window
public MainWindow()
{
AvaloniaXamlLoader.Load(this);
// InitializeComponent(), not AvaloniaXamlLoader.Load(this): only the
// generated method assigns the x:Name backing fields. Loading the XAML
// directly leaves every named control (ProfilesTree, the editor text
// boxes, FirstRunDatDirectoryTextBox, UpdateCloseButton, ...) null, so
// the first modal open or close threw NullReferenceException out of the
// dispatcher and took the whole process down through Program's guard.
InitializeComponent();
_statusTimer = new DispatcherTimer
{
Interval = TimeSpan.FromMilliseconds(250),