From d6ea0778a7da7765b187f8db2bb4c261fc25532b Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 1 Nov 2022 10:51:08 +0100 Subject: [PATCH] Make IsEvaluating re-entrancy friendly. --- src/Avalonia.Base/PropertyStore/ValueStore.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Base/PropertyStore/ValueStore.cs b/src/Avalonia.Base/PropertyStore/ValueStore.cs index 88ed0d73d5..4da24c1414 100644 --- a/src/Avalonia.Base/PropertyStore/ValueStore.cs +++ b/src/Avalonia.Base/PropertyStore/ValueStore.cs @@ -15,6 +15,7 @@ namespace Avalonia.PropertyStore private Dictionary? _localValueBindings; private AvaloniaPropertyDictionary _effectiveValues; private int _inheritedValueCount; + private int _isEvaluating; private int _frameGeneration; private int _styling; @@ -22,7 +23,7 @@ namespace Avalonia.PropertyStore public AvaloniaObject Owner { get; } public ValueStore? InheritanceAncestor { get; private set; } - public bool IsEvaluating { get; private set; } + public bool IsEvaluating => _isEvaluating > 0; public IReadOnlyList Frames => _frames; public void BeginStyling() => ++_styling; @@ -745,7 +746,7 @@ namespace Avalonia.PropertyStore EffectiveValue? current, bool ignoreLocalValue = false) { - IsEvaluating = true; + ++_isEvaluating; try { @@ -824,13 +825,13 @@ namespace Avalonia.PropertyStore } finally { - IsEvaluating = false; + --_isEvaluating; } } private void ReevaluateEffectiveValues() { - IsEvaluating = true; + ++_isEvaluating; try { @@ -903,7 +904,7 @@ namespace Avalonia.PropertyStore } finally { - IsEvaluating = false; + --_isEvaluating; } }