Skip to content

Commit

Permalink
fix: Possible null ref when initialiazing BindableImmutableList
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Nov 17, 2022
1 parent 9e77ddf commit d4f072e
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class BindableEnumerable<TCollection, TItem, TBindableItem> : Bi
private readonly BindablePropertyInfo<TCollection> _listProperty;
private readonly Func<BindablePropertyInfo<TItem>, TBindableItem> _bindableFactory;

private readonly Visitor _visitor;
private Visitor? _visitor;

/// <summary>
/// Creates a new instance
Expand All @@ -47,7 +47,6 @@ private protected BindableEnumerable(
{
_listProperty = property;
_bindableFactory = bindableFactory;
_visitor = new Visitor(this);
}

private protected abstract CollectionChangeSet<TItem> GetChanges(TCollection previous, TCollection current);
Expand All @@ -58,7 +57,7 @@ private protected override void UpdateSubProperties(TCollection previous, TColle
{
var collectionChanges = (changes as CollectionChangeSet<TItem> ?? GetChanges(previous, current));
base.UpdateSubProperties(previous, current, collectionChanges);
collectionChanges.Visit(_visitor);
collectionChanges.Visit(_visitor ??= new(this));
}

#region IList (read-only)
Expand Down

0 comments on commit d4f072e

Please sign in to comment.