Browse Source

Don't subscribe to inner observable if not active.

When subscribing to a `PropertySetterBindingInstance`, if the owner style is not active then there's no need to subscribe to the inner observable as this can cause resource lookups etc. Part of fixing #5027.
pull/5070/head
Steven Kirk 6 years ago
parent
commit
d8fbd95ef0
  1. 8
      src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs

8
src/Avalonia.Styling/Styling/PropertySetterBindingInstance.cs

@ -92,6 +92,7 @@ namespace Avalonia.Styling
{
if (!_isActive)
{
_innerSubscription ??= _binding.Observable.Subscribe(_inner);
_isActive = true;
PublishNext();
}
@ -102,6 +103,8 @@ namespace Avalonia.Styling
if (_isActive)
{
_isActive = false;
_innerSubscription?.Dispose();
_innerSubscription = null;
PublishNext();
}
}
@ -148,7 +151,10 @@ namespace Avalonia.Styling
protected override void Subscribed()
{
_innerSubscription = _binding.Observable.Subscribe(_inner);
if (_isActive)
{
_innerSubscription = _binding.Observable.Subscribe(_inner);
}
}
protected override void Unsubscribed()

Loading…
Cancel
Save