From 2bd3a4f5038c8ad8516bb522703666207607e9f2 Mon Sep 17 00:00:00 2001 From: "kwan.nguyen" Date: Thu, 19 Sep 2024 10:14:18 +0700 Subject: [PATCH] fix null pointer --- PCUT/PCUT/Package.appxmanifest | 2 +- .../Pages/DesignCenter/DesignCenterPage.xaml.cs | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/PCUT/PCUT/Package.appxmanifest b/PCUT/PCUT/Package.appxmanifest index cccbb17..c03a692 100644 --- a/PCUT/PCUT/Package.appxmanifest +++ b/PCUT/PCUT/Package.appxmanifest @@ -9,7 +9,7 @@ + Version="1.3.2.0" /> diff --git a/PCUT/PCUT/Pages/DesignCenter/DesignCenterPage.xaml.cs b/PCUT/PCUT/Pages/DesignCenter/DesignCenterPage.xaml.cs index 0dec773..ed593b3 100644 --- a/PCUT/PCUT/Pages/DesignCenter/DesignCenterPage.xaml.cs +++ b/PCUT/PCUT/Pages/DesignCenter/DesignCenterPage.xaml.cs @@ -149,7 +149,7 @@ namespace PCUT.Pages if (infos != null && infos.Any()) { var portInfos = new List(); - foreach (var info in infos) + foreach (var info in infos.Where(x => x.Id != null)) { using (var deviceInfo = await SerialDevice.FromIdAsync(info.Id)) { @@ -181,12 +181,12 @@ namespace PCUT.Pages private async void Refresh_Click(object sender, RoutedEventArgs e) { var deviceInfo = await GetPortInfos(); - viewModel.Ports.Clear(); - foreach (var info in deviceInfo) - viewModel.Ports.Add(info); - if (deviceInfo.Any()) - viewModel.SelectedPortIndex = 0; - } + viewModel.Ports.Clear(); + foreach (var info in deviceInfo) + viewModel.Ports.Add(info); + if (deviceInfo.Any()) + viewModel.SelectedPortIndex = 0; + } private void TextBox_BeforeTextChanging(TextBox sender, TextBoxBeforeTextChangingEventArgs args) {