From 172c0f521f5a2dc810334f976f0ca7fb715b7d42 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Mon, 8 Apr 2024 23:17:33 -0700 Subject: [PATCH 1/2] Migrate FlutterRestorationPlugin, FlutterTextureRegistryRelay, FlutterScreenAndSceneIfLoaded to ARC --- shell/platform/darwin/ios/BUILD.gn | 12 ++++++------ .../ios/framework/Source/FlutterRestorationPlugin.mm | 11 ++--------- .../framework/Source/FlutterTextureRegistryRelay.mm | 2 ++ ...UIViewController+FlutterScreenAndSceneIfLoaded.mm | 3 +++ 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 60f98dd61d5d6..6515ce60a8a2f 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -61,9 +61,15 @@ source_set("flutter_framework_source_arc") { sources = [ "framework/Source/FlutterMetalLayer.h", "framework/Source/FlutterMetalLayer.mm", + "framework/Source/FlutterRestorationPlugin.h", + "framework/Source/FlutterRestorationPlugin.mm", "framework/Source/FlutterTextInputDelegate.h", "framework/Source/FlutterTextInputPlugin.h", "framework/Source/FlutterTextInputPlugin.mm", + "framework/Source/FlutterTextureRegistryRelay.h", + "framework/Source/FlutterTextureRegistryRelay.mm", + "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h", + "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm", ] frameworks = [ @@ -110,14 +116,10 @@ source_set("flutter_framework_source") { "framework/Source/FlutterPlatformViews_Internal.h", "framework/Source/FlutterPlatformViews_Internal.mm", "framework/Source/FlutterPluginAppLifeCycleDelegate.mm", - "framework/Source/FlutterRestorationPlugin.h", - "framework/Source/FlutterRestorationPlugin.mm", "framework/Source/FlutterSemanticsScrollView.h", "framework/Source/FlutterSemanticsScrollView.mm", "framework/Source/FlutterSpellCheckPlugin.h", "framework/Source/FlutterSpellCheckPlugin.mm", - "framework/Source/FlutterTextureRegistryRelay.h", - "framework/Source/FlutterTextureRegistryRelay.mm", "framework/Source/FlutterUIPressProxy.h", "framework/Source/FlutterUIPressProxy.mm", "framework/Source/FlutterUndoManagerDelegate.h", @@ -131,8 +133,6 @@ source_set("flutter_framework_source") { "framework/Source/KeyCodeMap_Internal.h", "framework/Source/SemanticsObject.h", "framework/Source/SemanticsObject.mm", - "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h", - "framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm", "framework/Source/accessibility_bridge.h", "framework/Source/accessibility_bridge.mm", "framework/Source/accessibility_text_entry.h", diff --git a/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm index 4e11c4d19a708..bd4b52176dcda 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm @@ -9,7 +9,7 @@ #include "flutter/fml/logging.h" -FLUTTER_ASSERT_NOT_ARC +FLUTTER_ASSERT_ARC @interface FlutterRestorationPlugin () @property(nonatomic, copy) FlutterResult pendingRequest; @@ -54,8 +54,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { - (void)setRestorationData:(NSData*)data { if (data != _restorationData) { - [_restorationData release]; - _restorationData = [data retain]; + _restorationData = data; } _waitForData = NO; if (self.pendingRequest != nil) { @@ -91,10 +90,4 @@ - (NSDictionary*)dataForFramework { }; } -- (void)dealloc { - [_restorationData release]; - [_pendingRequest release]; - [super dealloc]; -} - @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.mm index 89377f0b4b561..1df2b05c4575d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.mm @@ -6,6 +6,8 @@ #include "flutter/fml/logging.h" +FLUTTER_ASSERT_ARC + @implementation FlutterTextureRegistryRelay : NSObject #pragma mark - FlutterTextureRegistry diff --git a/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm b/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm index 5eb4f71103056..b141b65768a0e 100644 --- a/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm +++ b/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm @@ -5,6 +5,9 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h" #include "flutter/fml/logging.h" +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" + +FLUTTER_ASSERT_ARC @implementation UIViewController (FlutterScreenAndSceneIfLoaded) From 3906c1dc9f778867db1ecf5d7c94a2ef5eb6e04b Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 10 Apr 2024 13:14:49 -0700 Subject: [PATCH 2/2] copy, weak --- .../darwin/ios/framework/Source/FlutterRestorationPlugin.h | 2 +- .../darwin/ios/framework/Source/FlutterRestorationPlugin.mm | 2 +- .../darwin/ios/framework/Source/FlutterTextureRegistryRelay.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.h b/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.h index dc437179c9e3d..bb7e1a7873ab8 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.h @@ -15,7 +15,7 @@ - (instancetype)initWithChannel:(FlutterMethodChannel*)channel restorationEnabled:(BOOL)waitForData NS_DESIGNATED_INITIALIZER; -@property(nonatomic, strong) NSData* restorationData; +@property(nonatomic, copy) NSData* restorationData; - (void)markRestorationComplete; - (void)reset; @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm index bd4b52176dcda..d06cba6c79ae6 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm @@ -54,7 +54,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { - (void)setRestorationData:(NSData*)data { if (data != _restorationData) { - _restorationData = data; + _restorationData = [data copy]; } _waitForData = NO; if (self.pendingRequest != nil) { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.h b/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.h index 26c19621fce97..2152ac55a370e 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.h @@ -22,7 +22,7 @@ FLUTTER_DARWIN_EXPORT /** * A weak reference to a FlutterEngine that will be passed texture registration. */ -@property(nonatomic, assign) NSObject* parent; +@property(nonatomic, weak) NSObject* parent; - (instancetype)initWithParent:(NSObject*)parent; @end