Skip to content

Commit

Permalink
Better null checking
Browse files Browse the repository at this point in the history
One test was crashing (even on rerun), so maybe this will fix
  • Loading branch information
jonathanpeppers authored and PureWeen committed May 16, 2024
1 parent 30fcc36 commit a9ff7f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,28 @@ public Cell Cell
get => _cell?.GetTargetOrDefault();
set
{
if (_cell is null)
{
_cell = new(value);
}
else
if (_cell is not null)
{
if (_cell.TryGetTarget(out var cell) && cell == value)
return;

if (cell != null)
if (cell is not null)
{
cell.PropertyChanged -= HandlePropertyChanged;
BeginInvokeOnMainThread(cell.SendDisappearing);
}
_cell = new(value);
}

if (value != null)
if (value is not null)
{
_cell = new(value);
value.PropertyChanged += HandlePropertyChanged;
BeginInvokeOnMainThread(value.SendAppearing);
}
else
{
_cell = null;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ public ViewCell ViewCell
get => _viewCell?.GetTargetOrDefault();
set
{
if (_viewCell is null)
{
_viewCell = new(value);
}
else
if (_viewCell is not null)
{
if (_viewCell.TryGetTarget(out var viewCell) && viewCell == value)
return;
Expand Down Expand Up @@ -192,15 +188,16 @@ void UpdateCell(ViewCell cell)
oldCell.View.MeasureInvalidated -= OnMeasureInvalidated;
}

_viewCell = new(cell);

if (cell is null)
{
_viewCell = null;
_rendererRef = null;
ContentView.ClearSubviews();
return;
}

_viewCell = new(cell);

cell.PropertyChanged += ViewCellPropertyChanged;
BeginInvokeOnMainThread(cell.SendAppearing);

Expand Down

0 comments on commit a9ff7f9

Please sign in to comment.