From b5d608e1c6b3b6813219f79dfab83c47ae8f6cee Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 12 May 2021 22:36:25 +0100 Subject: [PATCH] fixes from upstream, wraplayout. --- src/Avalonia.Layout/WrapLayout/WrapLayout.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Avalonia.Layout/WrapLayout/WrapLayout.cs b/src/Avalonia.Layout/WrapLayout/WrapLayout.cs index dccbb2205e..ded2afc3dd 100644 --- a/src/Avalonia.Layout/WrapLayout/WrapLayout.cs +++ b/src/Avalonia.Layout/WrapLayout/WrapLayout.cs @@ -236,6 +236,15 @@ namespace Avalonia.Layout // 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);