Skip to content

Commit

Permalink
Prevent UITextView from updating contentOffset while deallocating (#915)
Browse files Browse the repository at this point in the history
* Prevent UITextView from updating contentOffset while deallocating

* Add comment on the flag point to the issue
  • Loading branch information
maicki committed May 9, 2018
1 parent 4171e76 commit efe924c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- Adds an experiment to shorten init time. [Adlai Holler](https://github.com/Adlai-Holler)
- Adds a check that Texture is compiled with stdc++11 as specified by the podfile. gnu++11 can cause subtle issues that are currently being investigated. [Adlai Holler](https://github.com/Adlai-Holler)
- Adds an experiment to call ASNetworkImageNode callbacks off main. [Garrett Moon](https://github.com/garrettmoon)
- Prevent UITextView from updating contentOffset while deallocating [Michael Schneider](https://github.com/maicki)

## 2.6
- [Xcode 9] Updated to require Xcode 9 (to fix warnings) [Garrett Moon](https://github.com/garrettmoon)
Expand Down
21 changes: 20 additions & 1 deletion Source/TextKit/ASTextKitComponents.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -31,10 +34,16 @@ - (instancetype)initWithFrame:(CGRect)frame textContainer:(NSTextContainer *)tex
self = [super initWithFrame:frame textContainer:textContainer];
if (self) {
_threadSafeBounds = self.bounds;
_deallocating = NO;
}
return self;
}

- (void)dealloc
{
_deallocating = YES;
}

- (void)setFrame:(CGRect)frame
{
ASDisplayNodeAssertMainThread();
Expand All @@ -49,6 +58,16 @@ - (void)setBounds:(CGRect)bounds
self.threadSafeBounds = bounds;
}

- (void)setContentOffset:(CGPoint)contentOffset
{
if (_deallocating) {
return;
}

[super setContentOffset:contentOffset];
}


@end

@interface ASTextKitComponents ()
Expand Down

0 comments on commit efe924c

Please sign in to comment.