mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
[ASDisplayNode] Ensure that nil can never be returned from -measureWithSizeRange: (#2014)
* [ASDisplayNode] Ensure that nil can never be returned from -measureWithSizeRange: This can happen in rare cases when multiple relayouts occur while a transition is being measured. * [ASDisplayNode] Use ternary operator style for nil check.
This commit is contained in:
@@ -642,7 +642,8 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
{
|
||||
ASDN::MutexLocker l(__instanceLock__);
|
||||
if (! [self shouldMeasureWithSizeRange:constrainedSize]) {
|
||||
return _calculatedLayout;
|
||||
ASDisplayNodeAssertNotNil(_calculatedLayout, @"-[ASDisplayNode measureWithSizeRange:] _layout should not be nil! %@", self);
|
||||
return _calculatedLayout ? : [ASLayout layoutWithLayoutableObject:self constrainedSizeRange:constrainedSize size:CGSizeZero];
|
||||
}
|
||||
|
||||
[self cancelLayoutTransitionsInProgress];
|
||||
@@ -659,6 +660,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
[self _completePendingLayoutTransition];
|
||||
}
|
||||
|
||||
ASDisplayNodeAssertNotNil(newLayout, @"-[ASDisplayNode measureWithSizeRange:] newLayout should not be nil! %@", self);
|
||||
return newLayout;
|
||||
}
|
||||
|
||||
@@ -2071,6 +2073,8 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
|
||||
|
||||
layoutSpec.isMutable = NO;
|
||||
ASLayout *layout = [layoutSpec measureWithSizeRange:constrainedSize];
|
||||
ASDisplayNodeAssertNotNil(layout, @"[ASLayoutSpec measureWithSizeRange:] should never return nil! %@, %@", self, layoutSpec);
|
||||
|
||||
// Make sure layoutableObject of the root layout is `self`, so that the flattened layout will be structurally correct.
|
||||
BOOL isFinalLayoutable = (layout.layoutableObject != self);
|
||||
if (isFinalLayoutable) {
|
||||
|
||||
Reference in New Issue
Block a user