fix null pointer

This commit is contained in:
kwan.nguyen 2024-09-19 10:14:18 +07:00
parent e6545a2455
commit 2bd3a4f503
2 changed files with 8 additions and 8 deletions

View File

@ -9,7 +9,7 @@
<Identity <Identity
Name="ac171214-3336-4e02-845d-9bdc107cce71" Name="ac171214-3336-4e02-845d-9bdc107cce71"
Publisher="CN=pcut, O=PCUT, L=HN, S=HN, C=VN" Publisher="CN=pcut, O=PCUT, L=HN, S=HN, C=VN"
Version="1.3.1.0" /> Version="1.3.2.0" />
<mp:PhoneIdentity PhoneProductId="ac171214-3336-4e02-845d-9bdc107cce71" PhonePublisherId="00000000-0000-0000-0000-000000000000"/> <mp:PhoneIdentity PhoneProductId="ac171214-3336-4e02-845d-9bdc107cce71" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

View File

@ -149,7 +149,7 @@ namespace PCUT.Pages
if (infos != null && infos.Any()) if (infos != null && infos.Any())
{ {
var portInfos = new List<PortInfo>(); var portInfos = new List<PortInfo>();
foreach (var info in infos) foreach (var info in infos.Where(x => x.Id != null))
{ {
using (var deviceInfo = await SerialDevice.FromIdAsync(info.Id)) using (var deviceInfo = await SerialDevice.FromIdAsync(info.Id))
{ {
@ -181,12 +181,12 @@ namespace PCUT.Pages
private async void Refresh_Click(object sender, RoutedEventArgs e) private async void Refresh_Click(object sender, RoutedEventArgs e)
{ {
var deviceInfo = await GetPortInfos(); var deviceInfo = await GetPortInfos();
viewModel.Ports.Clear(); viewModel.Ports.Clear();
foreach (var info in deviceInfo) foreach (var info in deviceInfo)
viewModel.Ports.Add(info); viewModel.Ports.Add(info);
if (deviceInfo.Any()) if (deviceInfo.Any())
viewModel.SelectedPortIndex = 0; viewModel.SelectedPortIndex = 0;
} }
private void TextBox_BeforeTextChanging(TextBox sender, TextBoxBeforeTextChangingEventArgs args) private void TextBox_BeforeTextChanging(TextBox sender, TextBoxBeforeTextChangingEventArgs args)
{ {