Skip to content

Commit

Permalink
Fix the bug I introduced in #1030 (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adlai-Holler committed Jul 17, 2018
1 parent 6ed5ba2 commit cf810ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Source/Layout/ASLayout.mm
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ - (void)dealloc
{
if (_retainSublayoutElements.load()) {
for (ASLayout *sublayout in _sublayouts) {
CFRelease((__bridge CFTypeRef)sublayout);
// We retained this, so there's no risk of it deallocating on us.
if (let cfElement = (__bridge CFTypeRef)sublayout->_layoutElement) {
CFRelease(cfElement);
}
}
}
}
Expand All @@ -186,7 +189,8 @@ - (void)retainSublayoutElements
}

for (ASLayout *sublayout in _sublayouts) {
CFRetain((__bridge CFTypeRef)sublayout->_layoutElement);
// CFBridgingRetain atomically casts and retains. We need the atomicity.
CFBridgingRetain(sublayout->_layoutElement);
}
}

Expand Down

0 comments on commit cf810ac

Please sign in to comment.