From 08382e5bf554381a327e215b191d901ab4b16663 Mon Sep 17 00:00:00 2001 From: Max Katz Date: Sat, 15 May 2021 20:52:59 -0400 Subject: [PATCH] Fix SolidColorBrushAnimator NRE --- .../Animation/Animators/SolidColorBrushAnimator.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs index cec96fecf8..a56cc1de8c 100644 --- a/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs +++ b/src/Avalonia.Visuals/Animation/Animators/SolidColorBrushAnimator.cs @@ -12,6 +12,11 @@ namespace Avalonia.Animation.Animators { public override ISolidColorBrush Interpolate(double progress, ISolidColorBrush oldValue, ISolidColorBrush newValue) { + if (oldValue is null || newValue is null) + { + return oldValue; + } + return new ImmutableSolidColorBrush(ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color)); } @@ -26,6 +31,11 @@ namespace Avalonia.Animation.Animators { public override SolidColorBrush Interpolate(double progress, SolidColorBrush oldValue, SolidColorBrush newValue) { + if (oldValue is null || newValue is null) + { + return oldValue; + } + return new SolidColorBrush(ColorAnimator.InterpolateCore(progress, oldValue.Color, newValue.Color)); } }