From 55c2a5a2099dd10a9896c2f1be1952d77871b2e3 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 22 May 2026 07:25:47 -0400 Subject: [PATCH] fix(client-ui): resolve Medium code-review finding (Client.UI-002) Guard the two nullable child VM dereferences (BrowseTree at ConnectAsync and History at ViewHistoryForSelectedNode) with != null checks, matching the guarding style already used for Subscriptions and Alarms nearby. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../ViewModels/MainWindowViewModel.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client/ZB.MOM.WW.OtOpcUa.Client.UI/ViewModels/MainWindowViewModel.cs b/src/Client/ZB.MOM.WW.OtOpcUa.Client.UI/ViewModels/MainWindowViewModel.cs index fd28d36..c757bd6 100644 --- a/src/Client/ZB.MOM.WW.OtOpcUa.Client.UI/ViewModels/MainWindowViewModel.cs +++ b/src/Client/ZB.MOM.WW.OtOpcUa.Client.UI/ViewModels/MainWindowViewModel.cs @@ -252,7 +252,7 @@ public partial class MainWindowViewModel : ObservableObject } // Load root nodes - await BrowseTree.LoadRootsAsync(); + if (BrowseTree != null) await BrowseTree.LoadRootsAsync(); // Restore saved subscriptions if (_savedSubscribedNodes.Count > 0 && Subscriptions != null) @@ -330,7 +330,7 @@ public partial class MainWindowViewModel : ObservableObject if (SelectedTreeNodes.Count == 0 || !IsConnected) return; var node = SelectedTreeNodes[0]; - History.SelectedNodeId = node.NodeId; + if (History != null) History.SelectedNodeId = node.NodeId; SelectedTabIndex = 3; // History tab }