From dd5a7c93b955d6e170849debd4eae77311cc80ba Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 29 Sep 2022 20:31:01 +0200 Subject: [PATCH] Re-evaluate all properties if necessary. When re-evaluating a single property, if the frame activation state changes when unsubscribing from inactive frames then we need to re-evaluate all properties. --- src/Avalonia.Base/PropertyStore/ValueStore.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Base/PropertyStore/ValueStore.cs b/src/Avalonia.Base/PropertyStore/ValueStore.cs index 5f13a40da4..d917d73fd2 100644 --- a/src/Avalonia.Base/PropertyStore/ValueStore.cs +++ b/src/Avalonia.Base/PropertyStore/ValueStore.cs @@ -821,7 +821,11 @@ namespace Avalonia.PropertyStore current.Priority < BindingPriority.Unset && current.BasePriority < BindingPriority.Unset) { - UnsubscribeInactiveValues(i, property); + // If the active state of one of the trailing frames has changed since + // the last read, then we need to re-evaluate the effective values of all + // properties. + if (UnsubscribeInactiveValues(i, property)) + ReevaluateEffectiveValues(); return; } } @@ -948,9 +952,10 @@ namespace Avalonia.PropertyStore } } - private void UnsubscribeInactiveValues(int activeFrameIndex, AvaloniaProperty property) + private bool UnsubscribeInactiveValues(int activeFrameIndex, AvaloniaProperty property) { var foundBaseValue = _frames[activeFrameIndex].Priority != BindingPriority.Animation; + var activeChanged = false; for (var i = activeFrameIndex - 1; i >= 0; --i) { @@ -963,11 +968,15 @@ namespace Avalonia.PropertyStore } if ((foundBaseValue || frame.Priority <= BindingPriority.Animation) && - frame.TryGetEntryIfActive(property, out var entry, out _)) + frame.TryGetEntryIfActive(property, out var entry, out var changed)) { + if (changed && frame.EntryCount > 1) + activeChanged = true; entry.Unsubscribe(); } } + + return activeChanged; } private bool TryGetEffectiveValue(