Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent UITextView from updating contentOffset while deallocating #915

Merged
merged 2 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
20 changes: 19 additions & 1 deletion Source/TextKit/ASTextKitComponents.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

#import <tgmath.h>

@interface ASTextKitComponentsTextView ()
@interface ASTextKitComponentsTextView () {
BOOL _deallocating;
}
@property (atomic, assign) CGRect threadSafeBounds;
@end

Expand All @@ -31,10 +33,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 +57,16 @@ - (void)setBounds:(CGRect)bounds
self.threadSafeBounds = bounds;
}

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

[super setContentOffset:contentOffset];
}


@end

@interface ASTextKitComponents ()
Expand Down