mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-07 05:25:12 +00:00
Ensure that the uncommon __unloadNode codepath does not unintentionally trigger node removal.
This commit is contained in:
@@ -352,8 +352,9 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
||||
- (void)__unloadNode
|
||||
{
|
||||
ASDisplayNodeAssertThreadAffinity(self);
|
||||
ASDisplayNodeAssert([self isNodeLoaded], @"Implementation shouldn't call __unloadNode if not loaded: %@", self);
|
||||
ASDN::MutexLocker l(_propertyLock);
|
||||
|
||||
|
||||
if (_flags.layerBacked)
|
||||
_pendingViewState = [_ASPendingState pendingViewStateFromLayer:_layer];
|
||||
else
|
||||
|
||||
@@ -151,8 +151,11 @@
|
||||
needsSupernodeRemoval = YES;
|
||||
}
|
||||
} else {
|
||||
// If supernode is loaded but our superview is nil, the user manually removed us, so disconnect supernode.
|
||||
needsSupernodeRemoval = supernodeLoaded;
|
||||
// If supernode is loaded but our superview is nil, the user likely manually removed us, so disconnect supernode.
|
||||
// The unlikely alternative: we are in __unloadNode, with shouldRasterizeSubnodes just having been turned on.
|
||||
// In the latter case, we don't want to disassemble the node hierarchy because all views are intentionally being destroyed.
|
||||
BOOL nodeIsRasterized = ((_node.hierarchyState & ASHierarchyStateRasterized) == ASHierarchyStateRasterized);
|
||||
needsSupernodeRemoval = (supernodeLoaded && !nodeIsRasterized);
|
||||
}
|
||||
|
||||
if (needsSupernodeRemoval) {
|
||||
|
||||
@@ -798,8 +798,13 @@ static UIColor *defaultTintColor = nil;
|
||||
view.accessibilityIdentifier = accessibilityIdentifier;
|
||||
}
|
||||
|
||||
// FIXME: Make this more efficient by tracking which properties are set rather than reading everything.
|
||||
+ (_ASPendingState *)pendingViewStateFromLayer:(CALayer *)layer
|
||||
{
|
||||
if (!layer) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_ASPendingState *pendingState = [[_ASPendingState alloc] init];
|
||||
|
||||
pendingState.anchorPoint = layer.anchorPoint;
|
||||
@@ -877,8 +882,13 @@ static UIColor *defaultTintColor = nil;
|
||||
return pendingState;
|
||||
}
|
||||
|
||||
// FIXME: Make this more efficient by tracking which properties are set rather than reading everything.
|
||||
+ (_ASPendingState *)pendingViewStateFromView:(UIView *)view
|
||||
{
|
||||
if (!view) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_ASPendingState *pendingState = [[_ASPendingState alloc] init];
|
||||
|
||||
CALayer *layer = view.layer;
|
||||
|
||||
Reference in New Issue
Block a user