Skip to content

Commit

Permalink
fix(wasm): Image/AcrylicBrush.AssignAndObserveBrush exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoy312 committed Sep 22, 2021
1 parent 235b2d7 commit 73df35b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,12 @@ void refreshForeground()
#endif
}

_foregroundChanged.Disposable =
Brush.AssignAndObserveBrush(Foreground, c => refreshForeground(), refreshForeground);
_foregroundChanged.Disposable = null;
if (Foreground?.SupportsAssignAndObserveBrush ?? false)
{
_foregroundChanged.Disposable =
Brush.AssignAndObserveBrush(Foreground, c => refreshForeground(), refreshForeground);
}

refreshForeground();
}
Expand Down
12 changes: 8 additions & 4 deletions src/Uno.UI/UI/Xaml/Shapes/Shape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,17 @@ public DoubleCollection StrokeDashArray
#if LEGACY_SHAPE_MEASURE
protected virtual void OnFillChanged(Brush newValue)
{
_brushChanged.Disposable = Brush.AssignAndObserveBrush(newValue, _ =>
_brushChanged.Disposable = null;
if (newValue?.SupportsAssignAndObserveBrush ?? false)
{
_brushChanged.Disposable = Brush.AssignAndObserveBrush(newValue, _ =>
#if __WASM__
OnFillUpdatedPartial()
OnFillUpdatedPartial()
#else
RefreshShape(true)
RefreshShape(true)
#endif
);
);
}

OnFillUpdated(newValue);
}
Expand Down

0 comments on commit 73df35b

Please sign in to comment.