Browse Source

Only call coerce callback a single time.

pull/11501/head
Steven Kirk 3 years ago
parent
commit
531f059c76
  1. 5
      src/Avalonia.Base/PropertyStore/EffectiveValue`1.cs

5
src/Avalonia.Base/PropertyStore/EffectiveValue`1.cs

@ -208,7 +208,7 @@ namespace Avalonia.PropertyStore
IsOverridenCurrentValue = isOverriddenCurrentValue; IsOverridenCurrentValue = isOverriddenCurrentValue;
IsCoercedDefaultValue = isCoercedDefaultValue; IsCoercedDefaultValue = isCoercedDefaultValue;
if (_uncommon?._coerce is { } coerce) if (!isCoercedDefaultValue && _uncommon?._coerce is { } coerce)
v = coerce(owner.Owner, value); v = coerce(owner.Owner, value);
if (priority <= Priority) if (priority <= Priority)
@ -262,7 +262,8 @@ namespace Avalonia.PropertyStore
if (_uncommon?._coerce is { } coerce) if (_uncommon?._coerce is { } coerce)
{ {
v = coerce(owner.Owner, value); v = coerce(owner.Owner, value);
bv = coerce(owner.Owner, baseValue); if (priority != basePriority)
bv = coerce(owner.Owner, baseValue);
} }
if (!EqualityComparer<T>.Default.Equals(Value, v)) if (!EqualityComparer<T>.Default.Equals(Value, v))

Loading…
Cancel
Save