Bläddra i källkod

Fixed a bug where ValueStore.Changed could be called with pre-validation value

mstr2 6 år sedan
förälder
incheckning
e46cb67423
1 ändrade filer med 6 tillägg och 6 borttagningar
  1. 6 6
      src/Avalonia.Base/ValueStore.cs

+ 6 - 6
src/Avalonia.Base/ValueStore.cs

@@ -57,7 +57,8 @@ namespace Avalonia
                 {
                     if (priority == (int)BindingPriority.LocalValue)
                     {
-                        _propertyValues.SetValue(property, Validate(property, value));
+                        Validate(property, ref value);
+                        _propertyValues.SetValue(property, value);
                         Changed(property, priority, v, value);
                         return;
                     }
@@ -78,7 +79,8 @@ namespace Avalonia
 
                 if (priority == (int)BindingPriority.LocalValue)
                 {
-                    _propertyValues.AddValue(property, Validate(property, value));
+                    Validate(property, ref value);
+                    _propertyValues.AddValue(property, value);
                     Changed(property, priority, AvaloniaProperty.UnsetValue, value);
                     return;
                 }
@@ -166,16 +168,14 @@ namespace Avalonia
                 validate2);
         }
 
-        private object Validate(AvaloniaProperty property, object value)
+        private void Validate(AvaloniaProperty property, ref object value)
         {
             var validate = ((IStyledPropertyAccessor)property).GetValidationFunc(_owner.GetType());
 
             if (validate != null && value != AvaloniaProperty.UnsetValue)
             {
-                return validate(_owner, value);
+                value = validate(_owner, value);
             }
-
-            return value;
         }
 
         private DeferredSetter<T> GetDeferredSetter<T>(AvaloniaProperty property)