Prevent UITextView from updating contentOffset while deallocating (#915)

* Prevent UITextView from updating contentOffset while deallocating

* Add comment on the flag point to the issue
This commit is contained in:
Michael Schneider
2018-05-09 08:30:03 -07:00
committed by GitHub
parent 4171e767be
commit efe924cca7
2 changed files with 21 additions and 1 deletions

View File

@@ -20,7 +20,10 @@
#import <tgmath.h>
@interface ASTextKitComponentsTextView ()
@interface ASTextKitComponentsTextView () {
// Prevent UITextView from updating contentOffset while deallocating: https://github.com/TextureGroup/Texture/issues/860
BOOL _deallocating;
}
@property (atomic, assign) CGRect threadSafeBounds;
@end
@@ -31,10 +34,16 @@
self = [super initWithFrame:frame textContainer:textContainer];
if (self) {
_threadSafeBounds = self.bounds;
_deallocating = NO;
}
return self;
}
- (void)dealloc
{
_deallocating = YES;
}
- (void)setFrame:(CGRect)frame
{
ASDisplayNodeAssertMainThread();
@@ -49,6 +58,16 @@
self.threadSafeBounds = bounds;
}
- (void)setContentOffset:(CGPoint)contentOffset
{
if (_deallocating) {
return;
}
[super setContentOffset:contentOffset];
}
@end
@interface ASTextKitComponents ()