diff --git a/CHANGELOG.md b/CHANGELOG.md index f98a440dbe..3f38cdc875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - [ASEditableTextNode] added -editableTextNodeShouldBeginEditing to ASEditableTextNodeDelegate to mirror the corresponding method from UITextViewDelegate. [Yan S.](https://github.com/yans) [#535](https://github.com/TextureGroup/Texture/pull/535) - [Breaking] Remove APIs that have been deprecated since 2.0 and/or for at least 6 months [Huy Nguyen](https://github.com/nguyenhuy) [#529](https://github.com/TextureGroup/Texture/pull/529) - [ASDisplayNode] Ensure `-displayWillStartAsynchronously:` and `-displayDidFinish` are invoked on rasterized subnodes. [Eric Scheers](https://github.com/smeis) [#532](https://github.com/TextureGroup/Texture/pull/532) +- Fixed a memory corruption issue in the ASImageNode display system. [Adlai Holler](https://github.com/Adlai-Holler) [#555](https://github.com/TextureGroup/Texture/pull/555) ##2.4 - Fix an issue where inserting/deleting sections could lead to inconsistent supplementary element behavior. [Adlai Holler](https://github.com/Adlai-Holler) diff --git a/Source/Private/ASWeakMap.h b/Source/Private/ASWeakMap.h index fb53de15a2..18bf07184f 100644 --- a/Source/Private/ASWeakMap.h +++ b/Source/Private/ASWeakMap.h @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN AS_SUBCLASSING_RESTRICTED @interface ASWeakMapEntry : NSObject -@property (nonatomic, retain, readonly) Value value; +@property (atomic, strong, readonly) Value value; @end @@ -49,7 +49,7 @@ AS_SUBCLASSING_RESTRICTED * The underlying storage is a hash table and the Key type should implement `hash` and `isEqual:`. */ AS_SUBCLASSING_RESTRICTED -@interface ASWeakMap<__covariant Key : NSObject *, Value> : NSObject +@interface ASWeakMap<__covariant Key, Value> : NSObject /** * Read from the cache. The Value object is accessible from the returned ASWeakMapEntry. diff --git a/Source/Private/ASWeakMap.m b/Source/Private/ASWeakMap.m index 2d9eb55230..5d5b3dc1ad 100644 --- a/Source/Private/ASWeakMap.m +++ b/Source/Private/ASWeakMap.m @@ -18,12 +18,13 @@ #import @interface ASWeakMapEntry () -@property (nonatomic, strong) NSObject *key; +@property (nonatomic, strong, readonly) id key; +@property (atomic, strong) id value; @end @implementation ASWeakMapEntry -- (instancetype)initWithKey:(NSObject *)key value:(NSObject *)value +- (instancetype)initWithKey:(id)key value:(id)value { self = [super init]; if (self) { @@ -33,16 +34,11 @@ return self; } -- (void)setValue:(NSObject *)value -{ - _value = value; -} - @end @interface ASWeakMap () -@property (nonatomic, strong) NSMapTable *hashTable; +@property (nonatomic, strong, readonly) NSMapTable *hashTable; @end /** @@ -69,12 +65,12 @@ return self; } -- (ASWeakMapEntry *)entryForKey:(NSObject *)key +- (ASWeakMapEntry *)entryForKey:(id)key { return [self.hashTable objectForKey:key]; } -- (ASWeakMapEntry *)setObject:(NSObject *)value forKey:(NSObject *)key +- (ASWeakMapEntry *)setObject:(id)value forKey:(id)key { ASWeakMapEntry *entry = [self.hashTable objectForKey:key]; if (entry != nil) {