Skip to content

Commit

Permalink
chore: React to code review
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjohnoliver committed May 7, 2021
1 parent ff0cd13 commit 9d48d49
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/Uno.UI/UI/Xaml/DependencyObjectStore.Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ internal void SetBindingValue(DependencyPropertyDetails propertyDetails, object
{
// This guards against the scenario where inherited DataContext is removed when the view is removed from the visual tree,
// in which case 2-way bindings should not be updated.
if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
{
this.Log().DebugFormat("SetSourceValue() not called because inherited property is being unset.");
}
return;
}
_properties.SetSourceValue(propertyDetails, value);
Expand Down
46 changes: 25 additions & 21 deletions src/Uno.UI/UI/Xaml/DependencyObjectStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1586,27 +1586,7 @@ private void InvokeCallbacks(
{
for (var storeIndex = 0; storeIndex < _childrenStores.Count; storeIndex++)
{
var childStore = _childrenStores[storeIndex];
var propagateUnregistering = (_unregisteringInheritedProperties || _parentUnregisteringInheritedProperties) && property == _dataContextProperty;
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
try
#endif
{
if (propagateUnregistering)
{
childStore._parentUnregisteringInheritedProperties = true;
}
childStore.OnParentPropertyChangedCallback(instanceRef, property, eventArgs);
}
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
finally
#endif
{
if (propagateUnregistering)
{
childStore._parentUnregisteringInheritedProperties = false;
}
}
CallChildCallback(_childrenStores[storeIndex], instanceRef, property, eventArgs);
}
}
}
Expand Down Expand Up @@ -1644,6 +1624,30 @@ private void InvokeCallbacks(
}
}

private void CallChildCallback(DependencyObjectStore childStore, ManagedWeakReference instanceRef, DependencyProperty property, DependencyPropertyChangedEventArgs eventArgs)
{
var propagateUnregistering = (_unregisteringInheritedProperties || _parentUnregisteringInheritedProperties) && property == _dataContextProperty;
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
try
#endif
{
if (propagateUnregistering)
{
childStore._parentUnregisteringInheritedProperties = true;
}
childStore.OnParentPropertyChangedCallback(instanceRef, property, eventArgs);
}
#if !HAS_EXPENSIVE_TRYFINALLY // Try/finally incurs a very large performance hit in mono-wasm - https://github.com/dotnet/runtime/issues/50783
finally
#endif
{
if (propagateUnregistering)
{
childStore._parentUnregisteringInheritedProperties = false;
}
}
}

/// <summary>
/// Updates the parent of the <paramref name="newValue"/> to the
/// <paramref name="actualInstanceAlias"/> and resets the parent of <paramref name="previousValue"/>.
Expand Down

0 comments on commit 9d48d49

Please sign in to comment.