Skip to content

Commit

Permalink
Fix crash when attempting to change application whitelist (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyrrrz committed May 30, 2024
1 parent 3fe4963 commit e7791e3
Showing 1 changed file with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,25 @@ private void UserControl_OnLoaded(object? sender, RoutedEventArgs args)
private void WhitelistedApplicationsListBox_OnSelectionChanged(
object? sender,
SelectionChangedEventArgs args
) =>
DataContext.WhitelistedApplications = WhitelistedApplicationsListBox
)
{
var applications = WhitelistedApplicationsListBox
.SelectedItems?.Cast<ExternalApplication>()
.ToArray();

// Don't update the view model if the list hasn't changed.
// This is important to avoid potential infinite loops.
if (
applications is not null
&& DataContext.WhitelistedApplications is not null
&& applications.SequenceEqual(DataContext.WhitelistedApplications)
)
{
return;
}

DataContext.WhitelistedApplications = applications;
}

public void Dispose() => _eventRoot.Dispose();
}

0 comments on commit e7791e3

Please sign in to comment.