From 2144f920bec28d339d42fe76351768c7cb648951 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 29 Sep 2022 20:58:45 +0200 Subject: [PATCH] Re-evaluate all properties if necessary. Even if the frame's activation state has changed to false. --- src/Avalonia.Base/PropertyStore/ValueFrame.cs | 5 ++- src/Avalonia.Base/PropertyStore/ValueStore.cs | 36 +++++++++---------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/Avalonia.Base/PropertyStore/ValueFrame.cs b/src/Avalonia.Base/PropertyStore/ValueFrame.cs index c5cb18806d..e88affab3c 100644 --- a/src/Avalonia.Base/PropertyStore/ValueFrame.cs +++ b/src/Avalonia.Base/PropertyStore/ValueFrame.cs @@ -37,9 +37,8 @@ namespace Avalonia.PropertyStore [NotNullWhen(true)] out IValueEntry? entry, out bool activeChanged) { - if (_index.TryGetValue(property, out entry) && - GetIsActive(out activeChanged)) - return true; + if (_index.TryGetValue(property, out entry)) + return GetIsActive(out activeChanged); activeChanged = false; return false; } diff --git a/src/Avalonia.Base/PropertyStore/ValueStore.cs b/src/Avalonia.Base/PropertyStore/ValueStore.cs index d917d73fd2..eb97009355 100644 --- a/src/Avalonia.Base/PropertyStore/ValueStore.cs +++ b/src/Avalonia.Base/PropertyStore/ValueStore.cs @@ -787,30 +787,28 @@ namespace Avalonia.PropertyStore { var frame = _frames[i]; var priority = frame.Priority; + var foundEntry = frame.TryGetEntryIfActive(property, out var entry, out var activeChanged); + + // If the active state of the frame has changed since the last read, and + // the frame holds multiple values then we need to re-evaluate the + // effective values of all properties. + if (activeChanged && frame.EntryCount > 1) + { + ReevaluateEffectiveValues(); + return; + } - if (frame.TryGetEntryIfActive(property, out var entry, out var activeChanged)) + if (foundEntry && entry!.HasValue) { - // If The active state of the frame has changed since the last read, and - // the frame holds multiple values then we need to re-evaluate the - // effective values of all properties. - if (activeChanged && frame.EntryCount > 1) + if (current is not null) { - ReevaluateEffectiveValues(); - return; + current.SetAndRaise(this, entry, priority); } - - if (entry.HasValue) + else { - if (current is not null) - { - current.SetAndRaise(this, entry, priority); - } - else - { - current = property.CreateEffectiveValue(Owner); - AddEffectiveValue(property, current); - current.SetAndRaise(this, entry, priority); - } + current = property.CreateEffectiveValue(Owner); + AddEffectiveValue(property, current); + current.SetAndRaise(this, entry, priority); } }