Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid triggering main thread assertions in collection/table dealloc #trivial #803

Merged
merged 2 commits into from
Feb 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Source/ASCollectionNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,17 @@ - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionVi
return self;
}

#if ASDISPLAYNODE_ASSERTIONS_ENABLED
- (void)dealloc
{
if ([self isNodeLoaded]) {
ASDisplayNodeAssert(self.view.superview == nil, @"Node's view should be removed from hierarchy.");
if (self.nodeLoaded) {
__weak UIView *view = self.view;
ASPerformBlockOnMainThread(^{
ASDisplayNodeCAssertNil(view.superview, @"Node's view should be removed from hierarchy.");
});
}
}
#endif

#pragma mark ASDisplayNode

Expand Down
9 changes: 7 additions & 2 deletions Source/ASTableNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,17 @@ - (instancetype)init
return [self initWithStyle:UITableViewStylePlain];
}

#if ASDISPLAYNODE_ASSERTIONS_ENABLED
- (void)dealloc
{
if ([self isNodeLoaded]) {
ASDisplayNodeAssert(self.view.superview == nil, @"Node's view should be removed from hierarchy.");
if (self.nodeLoaded) {
__weak UIView *view = self.view;
ASPerformBlockOnMainThread(^{
ASDisplayNodeCAssertNil(view.superview, @"Node's view should be removed from hierarchy.");
});
}
}
#endif

#pragma mark ASDisplayNode

Expand Down