Skip to content

Commit

Permalink
FIXED: needed to use weak macro to support old OS #1161
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik committed Jun 28, 2019
1 parent 9b7e346 commit 92b34a9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Core/Source/DTAttributedTextContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ - (void)drawRect:(CGRect)rect

- (void)relayoutText
{
__weak typeof(self) weakSelf = self;
DT_WEAK_VARIABLE typeof(self) weakSelf = self;
DTBlockPerformSyncIfOnMainThreadElseAsync(^{
DTAttributedTextContentView *strongSelf = weakSelf;
// Make sure we actually have a superview and a previous layout before attempting to relayout the text.
Expand Down
4 changes: 2 additions & 2 deletions Core/Source/DTAttributedTextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ - (void)scrollRangeToVisible:(NSRange)range animated:(BOOL)animated

- (void)relayoutText
{
__weak typeof(self) weakSelf = self;
DT_WEAK_VARIABLE typeof(self) weakSelf = self;
DTBlockPerformSyncIfOnMainThreadElseAsync(^{
DTAttributedTextView *strongSelf = weakSelf;

Expand Down Expand Up @@ -168,7 +168,7 @@ - (CGRect)cursorRectAtIndex:(NSInteger)index
#pragma mark Notifications
- (void)contentViewDidLayout:(NSNotification *)notification
{
__weak typeof(self) weakSelf = self;
DT_WEAK_VARIABLE typeof(self) weakSelf = self;
DTBlockPerformSyncIfOnMainThreadElseAsync(^{
DTAttributedTextView *strongSelf = weakSelf;

Expand Down
12 changes: 6 additions & 6 deletions Core/Source/DTHTMLAttributedStringBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ - (BOOL)_buildString
// don't remove spaces at end of document
_preserverDocumentTrailingSpaces = [[_options objectForKey:DTDocumentPreserveTrailingSpaces] boolValue];

__weak typeof(self) weakSelf = self;
DT_WEAK_VARIABLE typeof(self) weakSelf = self;
__block BOOL result;
dispatch_group_async(_dataParsingGroup, _dataParsingQueue, ^{ result = [weakSelf.self->_parser parse]; });

Expand Down Expand Up @@ -702,7 +702,7 @@ - (void)_registerTagEndHandlers

- (void)parser:(DTHTMLParser *)parser didStartElement:(NSString *)elementName attributes:(NSDictionary *)attributeDict
{
__weak typeof(self) weakSelf = self;
DT_WEAK_VARIABLE typeof(self) weakSelf = self;
dispatch_group_async(_treeBuildingGroup, _treeBuildingQueue, ^{
DTHTMLAttributedStringBuilder *strongSelf = weakSelf;

Expand Down Expand Up @@ -814,7 +814,7 @@ - (void)parser:(DTHTMLParser *)parser didStartElement:(NSString *)elementName at
- (void)parser:(DTHTMLParser *)parser didEndElement:(NSString *)elementName
{

__weak typeof(self) weakSelf = self;
DT_WEAK_VARIABLE typeof(self) weakSelf = self;
dispatch_group_async(_treeBuildingGroup, _treeBuildingQueue, ^{
@autoreleasepool {
DTHTMLAttributedStringBuilder *strongSelf = weakSelf;
Expand Down Expand Up @@ -904,7 +904,7 @@ - (void)parser:(DTHTMLParser *)parser didEndElement:(NSString *)elementName

- (void)parser:(DTHTMLParser *)parser foundCharacters:(NSString *)string
{
__weak typeof(self) weakSelf = self;
DT_WEAK_VARIABLE typeof(self) weakSelf = self;
dispatch_group_async(_treeBuildingGroup, _treeBuildingQueue, ^{
DTHTMLAttributedStringBuilder *strongSelf = weakSelf;
if (strongSelf->_ignoreParseEvents)
Expand Down Expand Up @@ -971,7 +971,7 @@ - (void)parser:(DTHTMLParser *)parser foundCharacters:(NSString *)string

- (void)parser:(DTHTMLParser *)parser foundCDATA:(NSData *)CDATABlock
{
__weak typeof(self) weakSelf = self;
DT_WEAK_VARIABLE typeof(self) weakSelf = self;
dispatch_group_async(_treeBuildingGroup, _treeBuildingQueue, ^{
DTHTMLAttributedStringBuilder *strongSelf = weakSelf;

Expand All @@ -993,7 +993,7 @@ - (void)parser:(DTHTMLParser *)parser foundCDATA:(NSData *)CDATABlock

- (void)parserDidEndDocument:(DTHTMLParser *)parser
{
__weak typeof(self) weakSelf = self;
DT_WEAK_VARIABLE typeof(self) weakSelf = self;
dispatch_group_async(_treeBuildingGroup, _treeBuildingQueue, ^{
DTHTMLAttributedStringBuilder *strongSelf = weakSelf;

Expand Down
4 changes: 2 additions & 2 deletions Demo/Source/AutoLayoutDemoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@interface AutoLayoutDemoViewController ()

@property (nonatomic, weak) IBOutlet DTAttributedTextContentView *textView;
@property (nonatomic, DT_WEAK_PROPERTY) IBOutlet DTAttributedTextContentView *textView;
@end

@implementation AutoLayoutDemoViewController
Expand All @@ -24,4 +24,4 @@ - (void)viewDidLoad {
self.textView.attributedString = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL];
}

@end
@end

0 comments on commit 92b34a9

Please sign in to comment.