Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Leak mutex to avoid a crashing issue (facebook#22607)
Browse files Browse the repository at this point in the history
Summary:
Try to solve facebook#13588
ref: facebook/componentkit#906
Pull Request resolved: facebook#22607

Differential Revision: D14084056

Pulled By: shergin

fbshipit-source-id: 585aef758e1a215e825ae12914c5011d790a69b0
  • Loading branch information
chuganzy authored and JAStanton committed Feb 19, 2019
1 parent 8fd5bcc commit f6706f9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions React/Views/RCTFont.mm
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ static inline BOOL CompareFontWeights(UIFontWeight firstWeight, UIFontWeight sec
static UIFont *cachedSystemFont(CGFloat size, RCTFontWeight weight)
{
static NSCache *fontCache;
static std::mutex fontCacheMutex;
static std::mutex *fontCacheMutex = new std::mutex;

NSString *cacheKey = [NSString stringWithFormat:@"%.1f/%.2f", size, weight];
UIFont *font;
{
std::lock_guard<std::mutex> lock(fontCacheMutex);
std::lock_guard<std::mutex> lock(*fontCacheMutex);
if (!fontCache) {
fontCache = [NSCache new];
}
Expand All @@ -158,7 +158,7 @@ static inline BOOL CompareFontWeights(UIFontWeight firstWeight, UIFontWeight sec
}

{
std::lock_guard<std::mutex> lock(fontCacheMutex);
std::lock_guard<std::mutex> lock(*fontCacheMutex);
[fontCache setObject:font forKey:cacheKey];
}
}
Expand Down

0 comments on commit f6706f9

Please sign in to comment.