Skip to content

Commit 21dd5bf

Browse files
committed
Prevent a possible crash
1 parent 8212230 commit 21dd5bf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Core/src/Platform/iOS/ViewExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ internal static void InvalidateAncestorsMeasures(this UIView child)
320320
}
321321

322322
var superview = child.Superview;
323+
if (superview is null)
324+
{
325+
return;
326+
}
323327

324328
// Now invalidate the parent view
325329
var superviewMauiPlatformLayout = superview as IMauiPlatformView;
@@ -334,7 +338,7 @@ internal static void InvalidateAncestorsMeasures(this UIView child)
334338

335339
// Potential improvement: if the MAUI view (superview here) is constrained to a fixed size, we could stop propagating
336340
// when doing this, we must pay attention to a scenario where a non-fixed-size view becomes fixed-size
337-
if (superview is null or PageView or UIScrollView)
341+
if (superview is PageView or UIScrollView)
338342
{
339343
// We reached the root view or a scrollable area (includes collection view), stop propagating
340344
// The view will eventually watch its content size and invoke InvalidateMeasure when needed

0 commit comments

Comments
 (0)