Skip to content

Commit 95d738a

Browse files
authored
Fix: App crash if selected group is null when switching profiles (#1610)
* Fix: App crash if selected profile is null when switching profiles * Docs: Add #1610
1 parent 15b95c5 commit 95d738a

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Source/NETworkManager/ViewModels/ProfilesViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ public async void RefreshProfiles()
278278
{
279279
Groups?.Refresh();
280280

281-
// Set group again after refresh or first if null
282-
SelectedGroup = Groups.SourceCollection.Cast<GroupInfo>().FirstOrDefault(x => x.Name == _selectedGroup.Name) ?? Groups.SourceCollection.Cast<GroupInfo>().OrderBy(x => x.Name).FirstOrDefault();
281+
// Set group again after refresh or first if null (_selectedGroup can be null in some cases)
282+
SelectedGroup = Groups.SourceCollection.Cast<GroupInfo>().FirstOrDefault(x => x.Name == _selectedGroup?.Name) ?? Groups.SourceCollection.Cast<GroupInfo>().OrderBy(x => x.Name).FirstOrDefault();
283283
}));
284284

285285
_profileInfoOnRefresh = null;

docs/Changelog/next-release.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ permalink: /Changelog/next-release
5656
- Settings > Profiles
5757
- App crash fixed when a profile file is deleted and an encrypted but locked profile file is selected [#1512](https://github.com/BornToBeRoot/NETworkManager/pull/1512){:target="\_blank"}
5858
- Reselect group/profile on refresh (e.g. if profiles page is opened again) [#1516](https://github.com/BornToBeRoot/NETworkManager/pull/1516){:target="\_blank"}
59+
- App crash fixed when no group is selected and the profile file changes [#1610](https://github.com/BornToBeRoot/NETworkManager/pull/1610){:target="\_blank"}
5960

6061
## Other
6162
- Code cleanup [#1515](https://github.com/BornToBeRoot/NETworkManager/pull/1515){:target="\_blank"} [#1599](https://github.com/BornToBeRoot/NETworkManager/pull/1600){:target="\_blank"} [#1600](https://github.com/BornToBeRoot/NETworkManager/pull/1599){:target="\_blank"}

0 commit comments

Comments
 (0)