Skip to content

Commit

Permalink
Merge pull request AvaloniaUI#3258 from AvaloniaUI/fixes/binding-stac…
Browse files Browse the repository at this point in the history
…k-overflow

Alternative fix for binding stack overflow
  • Loading branch information
grokys authored Nov 15, 2019
2 parents b8717bf + 49b91d1 commit c5acd37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 132 deletions.
11 changes: 9 additions & 2 deletions src/Avalonia.Base/Reactive/AvaloniaPropertyBindingObservable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Avalonia.Data;

#nullable enable
Expand Down Expand Up @@ -47,8 +48,14 @@ private void PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property == _property)
{
_value = (T)e.NewValue;
PublishNext(new BindingValue<T>(_value));
var typedArgs = (AvaloniaPropertyChangedEventArgs<T>)e;
var newValue = e.Sender.GetValue(typedArgs.Property);

if (!typedArgs.OldValue.HasValue || !EqualityComparer<T>.Default.Equals(newValue, _value))
{
_value = newValue;
PublishNext(_value);
}
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/Avalonia.Base/Reactive/AvaloniaPropertyObservable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ private void PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e)
{
if (e.Property == _property)
{
_value = (T)e.NewValue;
PublishNext(_value);
var newValue = e.Sender.GetValue(e.Property);

if (!Equals(newValue, _value))
{
_value = (T)newValue;
PublishNext(_value);
}
}
}
}
Expand Down
128 changes: 0 additions & 128 deletions src/Avalonia.Base/Utilities/DeferredSetter.cs

This file was deleted.

0 comments on commit c5acd37

Please sign in to comment.