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

fix: Possible null ref when initialiazing BindableImmutableList #925

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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