Skip to content

Commit

Permalink
Use MutexLocker for safe locking and then access the ivars directly s…
Browse files Browse the repository at this point in the history
…o that another lock access is not required (TextureGroup#1662)
  • Loading branch information
Greg Bolsinga authored Sep 6, 2019
1 parent 00c03e8 commit a403160
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Source/ASImageNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -756,17 +756,16 @@ - (void)asyncTraitCollectionDidChangeWithPreviousTraitCollection:(ASPrimitiveTra
[super asyncTraitCollectionDidChangeWithPreviousTraitCollection:previousTraitCollection];

if (AS_AVAILABLE_IOS_TVOS(12, 10)) {
__instanceLock__.lock();
AS::MutexLocker l(__instanceLock__);
// update image if userInterfaceStyle was changed (dark mode)
if (_image != nil && self.primitiveTraitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle) {
UITraitCollection *tc = [UITraitCollection traitCollectionWithUserInterfaceStyle:self.primitiveTraitCollection.userInterfaceStyle];
if (_image != nil && _primitiveTraitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle) {
UITraitCollection *tc = [UITraitCollection traitCollectionWithUserInterfaceStyle:_primitiveTraitCollection.userInterfaceStyle];
// get an updated image from asset catalog
UIImage *updatedImage = [self.image.imageAsset imageWithTraitCollection:tc];
UIImage *updatedImage = [_image.imageAsset imageWithTraitCollection:tc];
if ( updatedImage != nil ) {
_image = updatedImage;
}
}
__instanceLock__.unlock();
}
}

Expand Down

0 comments on commit a403160

Please sign in to comment.