修复启动即崩溃:_settings 载入前就被读取

上一轮把「自动无障碍激活」开关接到 ControlTreeService 时,赋值语句被插到了
_settings = _settingsStore.Load() 之前,MainForm 构造时 _settings 还是 null,
启动直接 NullReferenceException(表现为「启动或转发失败(不会另开实例执行)」)。

现在把该赋值移到 _settings 载入之后。实测:真实 exe 启动后主窗口正常出现,
MainForm 构造/显示冒烟通过;回归 29/29 通过。
This commit is contained in:
zimoyin
2026-10-13 20:30:39 +08:00
parent c1e2bd29a1
commit 697d80fbcf
+2 -2
View File
@@ -326,10 +326,10 @@ namespace pacs_win_uia
_listReaderService = new ListReaderService(); _listReaderService = new ListReaderService();
_listResultExporter = new ListResultExporter(); _listResultExporter = new ListResultExporter();
_controlTreeService = new ControlTreeService(); _controlTreeService = new ControlTreeService();
// 自动无障碍激活跟着设置走(默认开)。
_controlTreeService.AutoActivateAccessibility = _settings.Ui.AutoActivateAccessibility;
_settingsStore = new Services.AppSettingsStore(); _settingsStore = new Services.AppSettingsStore();
_settings = _settingsStore.Load(); _settings = _settingsStore.Load();
// 自动无障碍激活跟着设置走(默认开)。必须在 _settings 载入之后再赋值。
_controlTreeService.AutoActivateAccessibility = _settings.Ui.AutoActivateAccessibility;
_ocrContext = OcrReadContext.Create(_settings.Ocr); _ocrContext = OcrReadContext.Create(_settings.Ocr);
_commandRunner = new Services.CommandRunner(); _commandRunner = new Services.CommandRunner();
_floatingBars = new FloatingBarManager(delegate { return _settings; }, this, FloatingBarOnActionInvoked); _floatingBars = new FloatingBarManager(delegate { return _settings; }, this, FloatingBarOnActionInvoked);