Skip to content

Commit

Permalink
Fix the bug I introduced in TextureGroup#1030 (TextureGroup#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adlai-Holler authored and mikezucc committed Oct 2, 2018
1 parent eba4864 commit dc7a8e0
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 dc7a8e0

Please sign in to comment.