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
Name="ac171214-3336-4e02-845d-9bdc107cce71"
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"/>

View File

@ -149,7 +149,7 @@ namespace PCUT.Pages
if (infos != null && infos.Any())
{
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))
{
@ -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)
{