Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5b95daf

Browse files
authored
Migrate FlutterRestorationPlugin, FlutterTextureRegistryRelay, FlutterScreenAndSceneIfLoaded to ARC (#51984)
Smart pointers support ARC as of #47612, and the unit tests were migrated in #48162. Migrate `FlutterRestorationPlugin`, `FlutterTextureRegistryRelay`, and `UIViewController+FlutterScreenAndSceneIfLoaded` from MRC to ARC. These files do not themselves import any MRC files, making them leaf nodes in the dependency graph of MRC files. Doing a few at a time to make the dependency graph manageable, and to easily revert if this causes retain cycles or other memory management issues. Part of flutter/flutter#137801.
1 parent 6f8ee9f commit 5b95daf

6 files changed

+15
-17
lines changed

shell/platform/darwin/ios/BUILD.gn

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,15 @@ source_set("flutter_framework_source_arc") {
6161
sources = [
6262
"framework/Source/FlutterMetalLayer.h",
6363
"framework/Source/FlutterMetalLayer.mm",
64+
"framework/Source/FlutterRestorationPlugin.h",
65+
"framework/Source/FlutterRestorationPlugin.mm",
6466
"framework/Source/FlutterTextInputDelegate.h",
6567
"framework/Source/FlutterTextInputPlugin.h",
6668
"framework/Source/FlutterTextInputPlugin.mm",
69+
"framework/Source/FlutterTextureRegistryRelay.h",
70+
"framework/Source/FlutterTextureRegistryRelay.mm",
71+
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h",
72+
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm",
6773
]
6874

6975
frameworks = [
@@ -110,14 +116,10 @@ source_set("flutter_framework_source") {
110116
"framework/Source/FlutterPlatformViews_Internal.h",
111117
"framework/Source/FlutterPlatformViews_Internal.mm",
112118
"framework/Source/FlutterPluginAppLifeCycleDelegate.mm",
113-
"framework/Source/FlutterRestorationPlugin.h",
114-
"framework/Source/FlutterRestorationPlugin.mm",
115119
"framework/Source/FlutterSemanticsScrollView.h",
116120
"framework/Source/FlutterSemanticsScrollView.mm",
117121
"framework/Source/FlutterSpellCheckPlugin.h",
118122
"framework/Source/FlutterSpellCheckPlugin.mm",
119-
"framework/Source/FlutterTextureRegistryRelay.h",
120-
"framework/Source/FlutterTextureRegistryRelay.mm",
121123
"framework/Source/FlutterUIPressProxy.h",
122124
"framework/Source/FlutterUIPressProxy.mm",
123125
"framework/Source/FlutterUndoManagerDelegate.h",
@@ -131,8 +133,6 @@ source_set("flutter_framework_source") {
131133
"framework/Source/KeyCodeMap_Internal.h",
132134
"framework/Source/SemanticsObject.h",
133135
"framework/Source/SemanticsObject.mm",
134-
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h",
135-
"framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm",
136136
"framework/Source/accessibility_bridge.h",
137137
"framework/Source/accessibility_bridge.mm",
138138
"framework/Source/accessibility_text_entry.h",

shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
- (instancetype)initWithChannel:(FlutterMethodChannel*)channel
1616
restorationEnabled:(BOOL)waitForData NS_DESIGNATED_INITIALIZER;
1717

18-
@property(nonatomic, strong) NSData* restorationData;
18+
@property(nonatomic, copy) NSData* restorationData;
1919
- (void)markRestorationComplete;
2020
- (void)reset;
2121
@end

shell/platform/darwin/ios/framework/Source/FlutterRestorationPlugin.mm

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include "flutter/fml/logging.h"
1111

12-
FLUTTER_ASSERT_NOT_ARC
12+
FLUTTER_ASSERT_ARC
1313

1414
@interface FlutterRestorationPlugin ()
1515
@property(nonatomic, copy) FlutterResult pendingRequest;
@@ -54,8 +54,7 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
5454

5555
- (void)setRestorationData:(NSData*)data {
5656
if (data != _restorationData) {
57-
[_restorationData release];
58-
_restorationData = [data retain];
57+
_restorationData = [data copy];
5958
}
6059
_waitForData = NO;
6160
if (self.pendingRequest != nil) {
@@ -91,10 +90,4 @@ - (NSDictionary*)dataForFramework {
9190
};
9291
}
9392

94-
- (void)dealloc {
95-
[_restorationData release];
96-
[_pendingRequest release];
97-
[super dealloc];
98-
}
99-
10093
@end

shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ FLUTTER_DARWIN_EXPORT
2222
/**
2323
* A weak reference to a FlutterEngine that will be passed texture registration.
2424
*/
25-
@property(nonatomic, assign) NSObject<FlutterTextureRegistry>* parent;
25+
@property(nonatomic, weak) NSObject<FlutterTextureRegistry>* parent;
2626
- (instancetype)initWithParent:(NSObject<FlutterTextureRegistry>*)parent;
2727
@end
2828

shell/platform/darwin/ios/framework/Source/FlutterTextureRegistryRelay.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#include "flutter/fml/logging.h"
88

9+
FLUTTER_ASSERT_ARC
10+
911
@implementation FlutterTextureRegistryRelay : NSObject
1012

1113
#pragma mark - FlutterTextureRegistry

shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#import "flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h"
66

77
#include "flutter/fml/logging.h"
8+
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
9+
10+
FLUTTER_ASSERT_ARC
811

912
@implementation UIViewController (FlutterScreenAndSceneIfLoaded)
1013

0 commit comments

Comments
 (0)