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

Migrate FlutterRestorationPlugin, FlutterTextureRegistryRelay, FlutterScreenAndSceneIfLoaded to ARC #51984

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "flutter/fml/logging.h"

FLUTTER_ASSERT_NOT_ARC
FLUTTER_ASSERT_ARC

@interface FlutterRestorationPlugin ()
@property(nonatomic, copy) FlutterResult pendingRequest;
Expand Down Expand Up @@ -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 copy];
}
_waitForData = NO;
if (self.pendingRequest != nil) {
Expand Down Expand Up @@ -91,10 +90,4 @@ - (NSDictionary*)dataForFramework {
};
}

- (void)dealloc {
[_restorationData release];
[_pendingRequest release];
[super dealloc];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ FLUTTER_DARWIN_EXPORT
/**
* A weak reference to a FlutterEngine that will be passed texture registration.
*/
@property(nonatomic, assign) NSObject<FlutterTextureRegistry>* parent;
@property(nonatomic, weak) NSObject<FlutterTextureRegistry>* parent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a place where we manually nil out this parent?

if we have it, we can remove it now; If we don't already have it, we may have dangling pointer problem which is fixed by this PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parent here is the FlutterEngine:


See also the last time we looked at this: #37666

I'll leave this for now, maybe we can do a sweep of these when I'm done ARC-ifying.

- (instancetype)initWithParent:(NSObject<FlutterTextureRegistry>*)parent;
@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "flutter/fml/logging.h"

FLUTTER_ASSERT_ARC

@implementation FlutterTextureRegistryRelay : NSObject

#pragma mark - FlutterTextureRegistry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down