Browse Source

Re-evaluate all properties if necessary.

Even if the frame's activation state has changed to false.
pull/8600/head
Steven Kirk 4 years ago
parent
commit
2144f920be
  1. 5
      src/Avalonia.Base/PropertyStore/ValueFrame.cs
  2. 36
      src/Avalonia.Base/PropertyStore/ValueStore.cs

5
src/Avalonia.Base/PropertyStore/ValueFrame.cs

@ -37,9 +37,8 @@ namespace Avalonia.PropertyStore
[NotNullWhen(true)] out IValueEntry? entry, [NotNullWhen(true)] out IValueEntry? entry,
out bool activeChanged) out bool activeChanged)
{ {
if (_index.TryGetValue(property, out entry) && if (_index.TryGetValue(property, out entry))
GetIsActive(out activeChanged)) return GetIsActive(out activeChanged);
return true;
activeChanged = false; activeChanged = false;
return false; return false;
} }

36
src/Avalonia.Base/PropertyStore/ValueStore.cs

@ -787,30 +787,28 @@ namespace Avalonia.PropertyStore
{ {
var frame = _frames[i]; var frame = _frames[i];
var priority = frame.Priority; 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 if (current is not null)
// the frame holds multiple values then we need to re-evaluate the
// effective values of all properties.
if (activeChanged && frame.EntryCount > 1)
{ {
ReevaluateEffectiveValues(); current.SetAndRaise(this, entry, priority);
return;
} }
else
if (entry.HasValue)
{ {
if (current is not null) current = property.CreateEffectiveValue(Owner);
{ AddEffectiveValue(property, current);
current.SetAndRaise(this, entry, priority); current.SetAndRaise(this, entry, priority);
}
else
{
current = property.CreateEffectiveValue(Owner);
AddEffectiveValue(property, current);
current.SetAndRaise(this, entry, priority);
}
} }
} }

Loading…
Cancel
Save