diff --git a/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm b/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm index b666f176eb6..2b3cc1f6cf5 100644 --- a/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentView.mm @@ -15,6 +15,8 @@ #import #import #import +#import + #import "RCTConversions.h" using namespace facebook::react; @@ -88,7 +90,7 @@ using namespace facebook::react; } RCTTextLayoutManager *nativeTextLayoutManager = - (__bridge RCTTextLayoutManager *)textLayoutManager->getNativeTextLayoutManager(); + (RCTTextLayoutManager *)unwrapManagedObject(textLayoutManager->getNativeTextLayoutManager()); CGRect frame = RCTCGRectFromRect(_layoutMetrics.getContentFrame()); @@ -128,7 +130,7 @@ using namespace facebook::react; } RCTTextLayoutManager *nativeTextLayoutManager = - (__bridge RCTTextLayoutManager *)textLayoutManager->getNativeTextLayoutManager(); + (RCTTextLayoutManager *)unwrapManagedObject(textLayoutManager->getNativeTextLayoutManager()); CGRect frame = RCTCGRectFromRect(_layoutMetrics.getContentFrame()); auto eventEmitter = [nativeTextLayoutManager getEventEmitterWithAttributeString:_state->getData().attributedString diff --git a/ReactCommon/fabric/textlayoutmanager/platform/ios/TextLayoutManager.h b/ReactCommon/fabric/textlayoutmanager/platform/ios/TextLayoutManager.h index 6abf45b979b..57478586edb 100644 --- a/ReactCommon/fabric/textlayoutmanager/platform/ios/TextLayoutManager.h +++ b/ReactCommon/fabric/textlayoutmanager/platform/ios/TextLayoutManager.h @@ -30,7 +30,6 @@ class TextLayoutManager { using Shared = std::shared_ptr; TextLayoutManager(ContextContainer::Shared const &contextContainer); - ~TextLayoutManager(); /* * Measures `attributedString` using native text rendering infrastructure. @@ -44,10 +43,10 @@ class TextLayoutManager { * Returns an opaque pointer to platform-specific TextLayoutManager. * Is used on a native views layer to delegate text rendering to the manager. */ - void *getNativeTextLayoutManager() const; + std::shared_ptr getNativeTextLayoutManager() const; private: - void *self_; + std::shared_ptr self_; TextMeasureCache measureCache_{}; }; diff --git a/ReactCommon/fabric/textlayoutmanager/platform/ios/TextLayoutManager.mm b/ReactCommon/fabric/textlayoutmanager/platform/ios/TextLayoutManager.mm index 345100b224e..6c28e51ff46 100644 --- a/ReactCommon/fabric/textlayoutmanager/platform/ios/TextLayoutManager.mm +++ b/ReactCommon/fabric/textlayoutmanager/platform/ios/TextLayoutManager.mm @@ -16,16 +16,10 @@ namespace react { TextLayoutManager::TextLayoutManager(ContextContainer::Shared const &contextContainer) { - self_ = (__bridge_retained void *)[RCTTextLayoutManager new]; + self_ = wrapManagedObject([RCTTextLayoutManager new]); } -TextLayoutManager::~TextLayoutManager() -{ - CFRelease(self_); - self_ = nullptr; -} - -void *TextLayoutManager::getNativeTextLayoutManager() const +std::shared_ptr TextLayoutManager::getNativeTextLayoutManager() const { assert(self_ && "Stored NativeTextLayoutManager must not be null."); return self_; @@ -36,7 +30,7 @@ Size TextLayoutManager::measure( ParagraphAttributes paragraphAttributes, LayoutConstraints layoutConstraints) const { - RCTTextLayoutManager *textLayoutManager = (__bridge RCTTextLayoutManager *)self_; + RCTTextLayoutManager *textLayoutManager = (RCTTextLayoutManager *)unwrapManagedObject(self_); auto size = Size{};