From 92b34a953cb9191c01622179ccf6a641a1399c2e Mon Sep 17 00:00:00 2001 From: Oliver Drobnik Date: Fri, 28 Jun 2019 16:07:09 +0200 Subject: [PATCH] FIXED: needed to use weak macro to support old OS #1161 --- Core/Source/DTAttributedTextContentView.m | 2 +- Core/Source/DTAttributedTextView.m | 4 ++-- Core/Source/DTHTMLAttributedStringBuilder.m | 12 ++++++------ Demo/Source/AutoLayoutDemoViewController.m | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Core/Source/DTAttributedTextContentView.m b/Core/Source/DTAttributedTextContentView.m index bb7e388bc..53b283709 100644 --- a/Core/Source/DTAttributedTextContentView.m +++ b/Core/Source/DTAttributedTextContentView.m @@ -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. diff --git a/Core/Source/DTAttributedTextView.m b/Core/Source/DTAttributedTextView.m index 25177b73e..05268b19a 100644 --- a/Core/Source/DTAttributedTextView.m +++ b/Core/Source/DTAttributedTextView.m @@ -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; @@ -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; diff --git a/Core/Source/DTHTMLAttributedStringBuilder.m b/Core/Source/DTHTMLAttributedStringBuilder.m index 0c63d4068..9e3ce097b 100644 --- a/Core/Source/DTHTMLAttributedStringBuilder.m +++ b/Core/Source/DTHTMLAttributedStringBuilder.m @@ -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]; }); @@ -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; @@ -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; @@ -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) @@ -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; @@ -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; diff --git a/Demo/Source/AutoLayoutDemoViewController.m b/Demo/Source/AutoLayoutDemoViewController.m index fababe1c4..d5f9ed74e 100644 --- a/Demo/Source/AutoLayoutDemoViewController.m +++ b/Demo/Source/AutoLayoutDemoViewController.m @@ -10,7 +10,7 @@ @interface AutoLayoutDemoViewController () -@property (nonatomic, weak) IBOutlet DTAttributedTextContentView *textView; +@property (nonatomic, DT_WEAK_PROPERTY) IBOutlet DTAttributedTextContentView *textView; @end @implementation AutoLayoutDemoViewController @@ -24,4 +24,4 @@ - (void)viewDidLoad { self.textView.attributedString = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL]; } -@end \ No newline at end of file +@end