From d3f8d08a47ce1a65c3f975d9d614f749792e6b88 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 12 Sep 2019 18:39:52 +0200 Subject: [PATCH] Make sure OneTime bindings unsubscribe. `OneTime` bindings unsubscribe when the first value is pushed, meaning that they unsubscribe _during_ `ExpressionNode.StartListeningCore`. Make sure we handle this by: - Setting `_listening = true` before calling `StartListeningCore` - Subscribe to current value in `InpcPropertyAccessorPlugin` before sending current value, because we're unsubscribed when `SendCurrentValue` exits --- src/Avalonia.Base/Data/Core/ExpressionNode.cs | 2 +- .../Data/Core/Plugins/InpcPropertyAccessorPlugin.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Base/Data/Core/ExpressionNode.cs b/src/Avalonia.Base/Data/Core/ExpressionNode.cs index ca7d980bcf..c2e5c8e4f3 100644 --- a/src/Avalonia.Base/Data/Core/ExpressionNode.cs +++ b/src/Avalonia.Base/Data/Core/ExpressionNode.cs @@ -140,8 +140,8 @@ namespace Avalonia.Data.Core } else if (target != AvaloniaProperty.UnsetValue) { - StartListeningCore(_target); _listening = true; + StartListeningCore(_target); } else { diff --git a/src/Avalonia.Base/Data/Core/Plugins/InpcPropertyAccessorPlugin.cs b/src/Avalonia.Base/Data/Core/Plugins/InpcPropertyAccessorPlugin.cs index 4716b45340..cbceb58204 100644 --- a/src/Avalonia.Base/Data/Core/Plugins/InpcPropertyAccessorPlugin.cs +++ b/src/Avalonia.Base/Data/Core/Plugins/InpcPropertyAccessorPlugin.cs @@ -103,8 +103,8 @@ namespace Avalonia.Data.Core.Plugins protected override void SubscribeCore() { - SendCurrentValue(); SubscribeToChanges(); + SendCurrentValue(); } protected override void UnsubscribeCore()