Don't allow unitialized or under constrained layouts cause a crash.

Should I move the pixel bounds rounding to here instead of leaving it in ASLayout?
This commit is contained in:
rcancro 2015-12-16 15:34:30 -08:00
parent 71c44843c8
commit 2e6e81e66b

View File

@ -1816,8 +1816,28 @@ void recursivelyEnsureDisplayForLayer(CALayer *layer)
CGRect subnodeFrame = CGRectZero;
for (ASLayout *subnodeLayout in _layout.sublayouts) {
ASDisplayNodeAssert([_subnodes containsObject:subnodeLayout.layoutableObject], @"Cached sublayouts must only contain subnodes' layout.");
subnodeFrame.origin = subnodeLayout.position;
subnodeFrame.size = subnodeLayout.size;
CGPoint adjustedOrigin = subnodeLayout.position;
if (isfinite(adjustedOrigin.x) == NO) {
ASDisplayNodeAssert(0, @"subnodeLayout has an invalid position");
adjustedOrigin.x = 0;
}
if (isfinite(adjustedOrigin.y) == NO) {
ASDisplayNodeAssert(0, @"subnodeLayout has an invalid position");
adjustedOrigin.y = 0;
}
subnodeFrame.origin = adjustedOrigin;
CGSize adjustedSize = subnodeLayout.size;
if (isfinite(adjustedSize.width) == NO) {
ASDisplayNodeAssert(0, @"subnodeLayout has an invalid size");
adjustedSize.width = 0;
}
if (isfinite(adjustedSize.height) == NO) {
ASDisplayNodeAssert(0, @"subnodeLayout has an invalid position");
adjustedSize.height = 0;
}
subnodeFrame.size = adjustedSize;
subnode = ((ASDisplayNode *)subnodeLayout.layoutableObject);
[subnode setFrame:subnodeFrame];
}