AvaloniaUI / Avalonia.Controls.TreeDataGrid

A combined TreeView/DataGrid for Avalonia.
MIT License
233 stars 48 forks source link

Check for null ItemsView in TreeSelectedItems. #301

Closed grokys closed 3 days ago

grokys commented 3 days ago

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.