Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for null ItemsView in TreeSelectedItems. #301

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

grokys
Copy link
Member

@grokys grokys commented Jul 2, 2024

A customer reported a NullReferenceException in TreeSelectedItemsBase:

Unexpected error: Object reference not set to an instance of an object.
  at Avalonia.Controls.Selection.TreeSelectedItemsBase`1.EnumerateNode(TreeSelectionNode`1 node)+MoveNext()
   at Avalonia.Controls.Selection.TreeSelectedItemsBase`1.EnumerateNode(TreeSelectionNode`1 node)+MoveNext()
   at Avalonia.Controls.Selection.TreeSelectedItemsBase`1.EnumerateNode(TreeSelectionNode`1 node)+MoveNext()
   at Avalonia.Controls.Selection.TreeSelectedItemsBase`1.EnumerateNode(TreeSelectionNode`1 node)+MoveNext()
   at Avalonia.Controls.Selection.TreeSelectedItemsBase`1.EnumerateNode(TreeSelectionNode`1 node)+MoveNext()
   at Avalonia.Controls.Selection.TreeSelectedItemsBase`1.EnumerateNode(TreeSelectionNode`1 node)+MoveNext()
   at Avalonia.Controls.Selection.TreeSelectedItemsBase`1.GetEnumerator()+MoveNext()
   at Avalonia.Controls.Selection.TreeSelectedItems`1.System.Collections.Generic.IEnumerable<System.Object>.GetEnumerator()+MoveNext()

The only thing that looks suspect is this ! operator in EnumerateNode. This PR puts a null check around that indexer instead of ignoring the null warning.

@grokys grokys merged commit d5d6496 into master Jul 3, 2024
3 checks passed
@grokys grokys deleted the fixes/nre-treeselecteditems branch July 3, 2024 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants