|
|
@@ -51,6 +51,12 @@ namespace Avalonia
|
|
|
/// </summary>
|
|
|
private EventHandler<AvaloniaPropertyChangedEventArgs> _propertyChanged;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Delayed setter helper for direct properties. Used to fix #855.
|
|
|
+ /// </summary>
|
|
|
+ protected readonly DelayedSetter<AvaloniaProperty, object> directDelayedSetter = new DelayedSetter<AvaloniaProperty, object>();
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// Initializes a new instance of the <see cref="AvaloniaObject"/> class.
|
|
|
/// </summary>
|
|
|
@@ -510,7 +516,6 @@ namespace Avalonia
|
|
|
{
|
|
|
Contract.Requires<ArgumentNullException>(property != null);
|
|
|
VerifyAccess();
|
|
|
- delayedSetter.SetNotifying(property, true);
|
|
|
|
|
|
AvaloniaPropertyChangedEventArgs e = new AvaloniaPropertyChangedEventArgs(
|
|
|
this,
|
|
|
@@ -537,12 +542,9 @@ namespace Avalonia
|
|
|
finally
|
|
|
{
|
|
|
property.Notifying?.Invoke(this, false);
|
|
|
- delayedSetter.SetNotifying(property, false);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private DelayedSetter<AvaloniaProperty> delayedSetter = new DelayedSetter<AvaloniaProperty>();
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// Sets the backing field for a direct avalonia property, raising the
|
|
|
/// <see cref="PropertyChanged"/> event if the value has changed.
|
|
|
@@ -557,17 +559,21 @@ namespace Avalonia
|
|
|
protected bool SetAndRaise<T>(AvaloniaProperty<T> property, ref T field, T value)
|
|
|
{
|
|
|
VerifyAccess();
|
|
|
- if (!delayedSetter.IsNotifying(property))
|
|
|
+ if (!directDelayedSetter.IsNotifying(property))
|
|
|
{
|
|
|
if (!object.Equals(field, value))
|
|
|
{
|
|
|
var old = field;
|
|
|
field = value;
|
|
|
- RaisePropertyChanged(property, old, value, BindingPriority.LocalValue);
|
|
|
+
|
|
|
+ using (directDelayedSetter.MarkNotifying(property))
|
|
|
+ {
|
|
|
+ RaisePropertyChanged(property, old, value, BindingPriority.LocalValue);
|
|
|
+ }
|
|
|
|
|
|
- if (delayedSetter.HasPendingSet(property))
|
|
|
+ if (directDelayedSetter.HasPendingSet(property))
|
|
|
{
|
|
|
- SetAndRaise(property, ref field, (T)delayedSetter.GetFirstPendingSet(property));
|
|
|
+ SetAndRaise(property, ref field, (T)directDelayedSetter.GetFirstPendingSet(property));
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
@@ -578,7 +584,7 @@ namespace Avalonia
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- delayedSetter.RecordPendingSet(property, value);
|
|
|
+ directDelayedSetter.AddPendingSet(property, value);
|
|
|
return false;
|
|
|
}
|
|
|
}
|