From a28a52dd64da50708691678ea644f55123ec77c5 Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Tue, 9 Jun 2020 12:37:54 -0700 Subject: [PATCH] Fabric: Using ManagedObjectWrapper in RCTTextLayoutManager Summary: While I was investigated the previous issue (T59430348) I found this place where we manipulate managed pointers manually. So, to make it error-prone this diff changes it to use `wrapManagedObject`. Changelog: [Internal] Fabric-specific internal change. Reviewed By: JoshuaGross Differential Revision: D21943010 fbshipit-source-id: ecaeffb419ae8d4880187027ca7ec9563e0dfd46 --- .../platform/ios/RCTTextLayoutManager.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm b/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm index 1029a87ad4a..9bd39d06624 100644 --- a/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm +++ b/ReactCommon/fabric/textlayoutmanager/platform/ios/RCTTextLayoutManager.mm @@ -10,12 +10,13 @@ #import "NSTextStorage+FontScaling.h" #import "RCTAttributedTextUtils.h" +#import #import using namespace facebook::react; @implementation RCTTextLayoutManager { - SimpleThreadSafeCache, 256> _cache; + SimpleThreadSafeCache, 256> _cache; } static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsizeMode) @@ -171,12 +172,11 @@ static NSLineBreakMode RCTNSLineBreakModeFromEllipsizeMode(EllipsizeMode ellipsi - (NSAttributedString *)_nsAttributedStringFromAttributedString:(AttributedString)attributedString { - auto sharedNSAttributedString = _cache.get(attributedString, [](const AttributedString attributedString) { - return std::shared_ptr( - (__bridge_retained void *)RCTNSAttributedStringFromAttributedString(attributedString), CFRelease); + auto sharedNSAttributedString = _cache.get(attributedString, [](AttributedString attributedString) { + return wrapManagedObject(RCTNSAttributedStringFromAttributedString(attributedString)); }); - return (__bridge NSAttributedString *)sharedNSAttributedString.get(); + return unwrapManagedObject(sharedNSAttributedString); } @end