Skip to content

Commit 13c1566

Browse files
authored
iOS: Make FlutterViewController.engine a strong ref (flutter/engine#56663)
Previously, FlutterViewController.engine was declared as a weak readonly property, but we explicitly declared the `FlutterEngine* _engine` ivar as a strong reference in the implementation. This changes the property declaration to be strong and eliminates the now unnecessary ivar. There is also no semantic change to FlutterViewController itself, since the `_engine` ivar had been manually declared as a strong reference. There is no semantic change for users of FlutterViewController.engine since whether a user acquires a strong or weak reference to the engine is determined by whether they declare the pointer to which they assign it as strong or weak. This also eliminates the need for the `engine` getter, which was only present to prevent a warning that the strong ivar didn't match the weak property declaration. No changes to tests since this introduces no semantic changes. Issue: flutter#137801 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 20e0482 commit 13c1566

File tree

2 files changed

+1
-6
lines changed

2 files changed

+1
-6
lines changed

engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ FLUTTER_DARWIN_EXPORT
233233
* `FlutterViewController` is initialized with or a new `FlutterEngine` implicitly created if
234234
* no engine was supplied during initialization.
235235
*/
236-
@property(weak, nonatomic, readonly) FlutterEngine* engine;
236+
@property(nonatomic, readonly) FlutterEngine* engine;
237237

238238
/**
239239
* The `FlutterBinaryMessenger` associated with this FlutterViewController (used for communicating

engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ - (void)handleKeyboardAnimationCallbackWithTargetTime:(fml::TimePoint)targetTime
153153
@end
154154

155155
@implementation FlutterViewController {
156-
FlutterEngine* _engine;
157156
flutter::ViewportMetrics _viewportMetrics;
158157
MouseState _mouseState;
159158
}
@@ -302,10 +301,6 @@ - (void)performCommonViewControllerInitialization {
302301
[self setUpNotificationCenterObservers];
303302
}
304303

305-
- (FlutterEngine*)engine {
306-
return _engine;
307-
}
308-
309304
- (void)setUpNotificationCenterObservers {
310305
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
311306
[center addObserver:self

0 commit comments

Comments
 (0)