Skip to content

Commit

Permalink
fix: Fix possible non disposed tracing.
Browse files Browse the repository at this point in the history
  • Loading branch information
dr1rrb committed Feb 3, 2021
1 parent 270bf34 commit 2bd607b
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/Uno.UI/UI/Xaml/Controls/Layouter/Layouter.cs
Expand Up @@ -77,15 +77,13 @@ protected Layouter(IFrameworkElement element)
/// <returns>The size of the panel, in logical pixel.</returns>
public Size Measure(Size availableSize)
{
IDisposable traceActivity = null;
if (_trace.IsEnabled)
{
traceActivity = _trace.WriteEventActivity(
using var traceActivity = _trace.IsEnabled
? _trace.WriteEventActivity(
FrameworkElement.TraceProvider.FrameworkElement_MeasureStart,
FrameworkElement.TraceProvider.FrameworkElement_MeasureStop,
new object[] { LoggingOwnerTypeName, Panel.GetDependencyObjectId() }
);
}
new object[] {LoggingOwnerTypeName, Panel.GetDependencyObjectId()}
)
: null;

if (Panel.Visibility == Visibility.Collapsed)
{
Expand Down Expand Up @@ -154,7 +152,6 @@ public Size Measure(Size availableSize)
{
UIElement.IsLayoutingVisualTreeRoot = false;
}
traceActivity?.Dispose();
}
}

Expand All @@ -178,15 +175,13 @@ public void Arrange(Rect finalRect)
{
LayoutInformation.SetLayoutSlot(Panel, finalRect);

IDisposable traceActivity = null;
if (_trace.IsEnabled)
{
traceActivity = _trace.WriteEventActivity(
using var traceActivity = _trace.IsEnabled
? _trace.WriteEventActivity(
FrameworkElement.TraceProvider.FrameworkElement_ArrangeStart,
FrameworkElement.TraceProvider.FrameworkElement_ArrangeStop,
new object[] { LoggingOwnerTypeName, Panel.GetDependencyObjectId() }
);
}
new object[] {LoggingOwnerTypeName, Panel.GetDependencyObjectId()}
)
: null;

try
{
Expand Down Expand Up @@ -288,7 +283,6 @@ public void Arrange(Rect finalRect)
{
UIElement.IsLayoutingVisualTreeRoot = false;
}
traceActivity?.Dispose();
}
}

Expand Down

0 comments on commit 2bd607b

Please sign in to comment.