Skip to content

Commit

Permalink
Merge pull request #5913 from AvaloniaUI/upstream-wrap-layout-fixes
Browse files Browse the repository at this point in the history
fixes from upstream, wraplayout.
  • Loading branch information
MarchingCube committed May 17, 2021
2 parents 9810e80 + 656a3ac commit 6b4d672
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Avalonia.Layout/WrapLayout/WrapLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,15 @@ protected internal override Size MeasureOverride(VirtualizingLayoutContext conte
// for the last condition it is zeros so adding it will make no difference
// this way is faster than an if condition in every loop for checking the last item
totalMeasure.U = parentMeasure.U;

// Propagating an infinite size causes a crash. This can happen if the parent is scrollable and infinite in the opposite
// axis to the panel. Clearing to zero prevents the crash.
// This is likely an incorrect use of the control by the developer, however we need stability here so setting a default that wont crash.
if (double.IsInfinity(totalMeasure.U))
{
totalMeasure.U = 0.0;
}

totalMeasure.V = state.GetHeight();

totalMeasure.U = Math.Ceiling(totalMeasure.U);
Expand Down

0 comments on commit 6b4d672

Please sign in to comment.