Browse Source

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

pull/856/head
Jeremy Koritzinsky 9 years ago
parent
commit
a02515fe19
  1. 3
      src/Avalonia.Base/AvaloniaObject.cs
  2. 4
      src/Avalonia.Base/PriorityValue.cs
  3. 9
      src/Avalonia.Base/Utilities/DeferredSetter.cs

3
src/Avalonia.Base/AvaloniaObject.cs

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

4
src/Avalonia.Base/PriorityValue.cs

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

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

Loading…
Cancel
Save