Przeglądaj źródła

Make pending set condition always !object.Equals since the other condition in PriorityValue didn't match expected behavior as per new unit tests.

Jeremy Koritzinsky 8 lat temu
rodzic
commit
a02515fe19

+ 1 - 2
src/Avalonia.Base/AvaloniaObject.cs

@@ -603,8 +603,7 @@ namespace Avalonia
                     setterCallback((T)val, ref backing, notify);
                     return true;
                 },
-                value,
-                (object o, ref T backing) => !object.Equals(o, backing));
+                value);
         }
 
         /// <summary>

+ 1 - 3
src/Avalonia.Base/PriorityValue.cs

@@ -246,9 +246,7 @@ namespace Avalonia
             delayedSetter.SetAndNotify(this,
                 ref _value,
                 UpdateCore,
-                (value, priority),
-                ((object value, int) val, ref (object value, int) backing)
-                    => !object.Equals(val.value, backing.value));
+                (value, priority));
         }
 
         private bool UpdateCore(

+ 3 - 6
src/Avalonia.Base/Utilities/DeferredSetter.cs

@@ -103,7 +103,6 @@ namespace Avalonia.Utilities
         }
 
         public delegate bool SetterDelegate<TValue>(TSetRecord record, ref TValue backing, Action<Action> notifyCallback);
-        public delegate bool PendingSetPredicate<TValue>(TSetRecord record, ref TValue backing);
 
         /// <summary>
         /// Set the property and notify listeners while ensuring we don't get into a stack overflow as happens with #855 and #824
@@ -120,15 +119,13 @@ namespace Avalonia.Utilities
             TProperty property,
             ref TValue backing,
             SetterDelegate<TValue> setterCallback,
-            TSetRecord value,
-            PendingSetPredicate<TValue> pendingSetCondition)
+            TSetRecord value)
         {
             Contract.Requires<ArgumentNullException>(setterCallback != null);
-            Contract.Requires<ArgumentNullException>(pendingSetCondition != null);
             if (!IsNotifying(property))
             {
                 bool updated = false;
-                if (pendingSetCondition(value, ref backing))
+                if (!object.Equals(value, backing))
                 {
                     updated = setterCallback(value, ref backing, notification =>
                     {
@@ -150,7 +147,7 @@ namespace Avalonia.Utilities
                 }
                 return updated;
             }
-            else if(pendingSetCondition(value, ref backing))
+            else if(!object.Equals(value, backing))
             {
                 AddPendingSet(property, value);
             }