mirror of
https://github.com/TextureGroup/Texture.git
synced 2026-04-07 19:17:39 +00:00
use lock to avoid crash when image might be changed during the trait collection change (#1651)
This commit is contained in:
@@ -756,6 +756,7 @@ static ASWeakMap<ASImageNodeContentsKey *, UIImage *> *cache = nil;
|
||||
[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];
|
||||
@@ -764,9 +765,8 @@ static ASWeakMap<ASImageNodeContentsKey *, UIImage *> *cache = nil;
|
||||
if ( updatedImage != nil ) {
|
||||
_image = updatedImage;
|
||||
}
|
||||
// trigger needs display anyway, cause image might be dynamic itself (e.g. dynamic tint color)
|
||||
[self setNeedsDisplay];
|
||||
}
|
||||
__instanceLock__.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user