Skip to content

Commit

Permalink
use lock to avoid crash when image might be changed during the trait …
Browse files Browse the repository at this point in the history
…collection change
  • Loading branch information
vovasty committed Aug 30, 2019
1 parent 0cd5561 commit d0eabb6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Source/ASImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ - (void)asyncTraitCollectionDidChangeWithPreviousTraitCollection:(ASPrimitiveTra
[super asyncTraitCollectionDidChangeWithPreviousTraitCollection:previousTraitCollection];

if (AS_AVAILABLE_IOS_TVOS(12, 10)) {
__instanceLock__.lock();
// update image if userInterfaceStyle was changed (dark mode)
if (_image != nil && self.primitiveTraitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle) {
UITraitCollection *tc = [UITraitCollection traitCollectionWithUserInterfaceStyle:self.primitiveTraitCollection.userInterfaceStyle];
Expand All @@ -764,9 +765,8 @@ - (void)asyncTraitCollectionDidChangeWithPreviousTraitCollection:(ASPrimitiveTra
if ( updatedImage != nil ) {
_image = updatedImage;
}
// trigger needs display anyway, cause image might be dynamic itself (e.g. dynamic tint color)
[self setNeedsDisplay];
}
__instanceLock__.unlock();
}
}

Expand Down

0 comments on commit d0eabb6

Please sign in to comment.