mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-21 05:39:01 +00:00
Remove threading assumption in ASDisplayNode measureWithSizeRange:"
This commit is contained in:
parent
5e49cc4382
commit
f59eb98749
@ -610,12 +610,20 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
|||||||
|
|
||||||
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
|
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
|
||||||
{
|
{
|
||||||
return [self measureWithSizeRange:constrainedSize completion:^{
|
void (^manageSubnodesBlock)() = ^void() {
|
||||||
if (self.usesImplicitHierarchyManagement) {
|
if (self.usesImplicitHierarchyManagement) {
|
||||||
[self __implicitlyInsertSubnodes];
|
[self __implicitlyInsertSubnodes];
|
||||||
[self __implicitlyRemoveSubnodes];
|
[self __implicitlyRemoveSubnodes];
|
||||||
}
|
}
|
||||||
[self __completeLayoutCalculation];
|
[self __completeLayoutCalculation];
|
||||||
|
};
|
||||||
|
|
||||||
|
return [self measureWithSizeRange:constrainedSize completion:^{
|
||||||
|
if (!self.isNodeLoaded) {
|
||||||
|
manageSubnodesBlock();
|
||||||
|
} else {
|
||||||
|
ASPerformBlockOnMainThread(manageSubnodesBlock);
|
||||||
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,18 +704,15 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c)
|
|||||||
|
|
||||||
- (void)__completeLayoutCalculation
|
- (void)__completeLayoutCalculation
|
||||||
{
|
{
|
||||||
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
_insertedSubnodes = nil;
|
_insertedSubnodes = nil;
|
||||||
_removedSubnodes = nil;
|
_removedSubnodes = nil;
|
||||||
_previousLayout = nil;
|
_previousLayout = nil;
|
||||||
|
|
||||||
[self calculatedLayoutDidChange];
|
[self calculatedLayoutDidChange];
|
||||||
|
|
||||||
// we generate placeholders at measureWithSizeRange: time so that a node is guaranteed
|
// we generate placeholders at measureWithSizeRange: time so that a node is guaranteed
|
||||||
// to have a placeholder ready to go. Also, if a node has no size it should not have a placeholder
|
// to have a placeholder ready to go. Also, if a node has no size it should not have a placeholder
|
||||||
[self __initPlaceholder];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)__initPlaceholder
|
|
||||||
{
|
|
||||||
if (self.placeholderEnabled && [self _displaysAsynchronously] &&
|
if (self.placeholderEnabled && [self _displaysAsynchronously] &&
|
||||||
_layout.size.width > 0.0 && _layout.size.height > 0.0) {
|
_layout.size.width > 0.0 && _layout.size.height > 0.0) {
|
||||||
if (!_placeholderImage) {
|
if (!_placeholderImage) {
|
||||||
@ -803,6 +808,7 @@ static inline void filterNodesInLayoutAtIndexesWithIntersectingNodes(
|
|||||||
|
|
||||||
- (void)__implicitlyInsertSubnodes
|
- (void)__implicitlyInsertSubnodes
|
||||||
{
|
{
|
||||||
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
for (NSInteger i = 0; i < [_insertedSubnodes count]; i++) {
|
for (NSInteger i = 0; i < [_insertedSubnodes count]; i++) {
|
||||||
NSInteger p = _insertedSubnodePositions[i];
|
NSInteger p = _insertedSubnodePositions[i];
|
||||||
[self insertSubnode:_insertedSubnodes[i] atIndex:p];
|
[self insertSubnode:_insertedSubnodes[i] atIndex:p];
|
||||||
@ -811,6 +817,7 @@ static inline void filterNodesInLayoutAtIndexesWithIntersectingNodes(
|
|||||||
|
|
||||||
- (void)__implicitlyRemoveSubnodes
|
- (void)__implicitlyRemoveSubnodes
|
||||||
{
|
{
|
||||||
|
ASDN::MutexLocker l(_propertyLock);
|
||||||
for (NSInteger i = 0; i < [_removedSubnodes count]; i++) {
|
for (NSInteger i = 0; i < [_removedSubnodes count]; i++) {
|
||||||
[_removedSubnodes[i] removeFromSupernode];
|
[_removedSubnodes[i] removeFromSupernode];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user