Skip to content

Commit

Permalink
Move clearing out of ASTextKitComponents property delegates into ASTe…
Browse files Browse the repository at this point in the history
…xtKitComponents dealloc (TextureGroup#591)
  • Loading branch information
maicki authored and bernieperez committed Apr 25, 2018
1 parent 408a46e commit f1ccff1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
7 changes: 0 additions & 7 deletions Source/ASEditableTextNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,6 @@ - (instancetype)initWithTextKitComponents:(ASTextKitComponents *)textKitComponen
return self;
}

- (void)dealloc
{
_textKitComponents.textView.delegate = nil;
_textKitComponents.layoutManager.delegate = nil;
_placeholderTextKitComponents.layoutManager.delegate = nil;
}

#pragma mark - ASDisplayNode Overrides
- (void)didLoad
{
Expand Down
15 changes: 14 additions & 1 deletion Source/TextKit/ASTextKitComponents.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// ASTextKitComponents.m
// ASTextKitComponents.mm
// Texture
//
// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.
Expand Down Expand Up @@ -30,6 +30,8 @@ @interface ASTextKitComponents ()

@implementation ASTextKitComponents

#pragma mark - Class

+ (instancetype)componentsWithAttributedSeedString:(NSAttributedString *)attributedSeedString
textContainerSize:(CGSize)textContainerSize
{
Expand Down Expand Up @@ -58,6 +60,17 @@ + (instancetype)componentsWithTextStorage:(NSTextStorage *)textStorage
return components;
}

#pragma mark - Lifecycle

- (void)dealloc
{
// Nil out all delegate to prevent crash
_textView.delegate = nil;
_layoutManager.delegate = nil;
}

#pragma mark - Sizing

- (CGSize)sizeForConstrainedWidth:(CGFloat)constrainedWidth
{
ASTextKitComponents *components = self;
Expand Down

0 comments on commit f1ccff1

Please sign in to comment.