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: https://github.com/flutter/flutter/issues/137801 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
parent
20e0482db7
commit
13c156630a
@ -233,7 +233,7 @@ FLUTTER_DARWIN_EXPORT
|
|||||||
* `FlutterViewController` is initialized with or a new `FlutterEngine` implicitly created if
|
* `FlutterViewController` is initialized with or a new `FlutterEngine` implicitly created if
|
||||||
* no engine was supplied during initialization.
|
* no engine was supplied during initialization.
|
||||||
*/
|
*/
|
||||||
@property(weak, nonatomic, readonly) FlutterEngine* engine;
|
@property(nonatomic, readonly) FlutterEngine* engine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The `FlutterBinaryMessenger` associated with this FlutterViewController (used for communicating
|
* The `FlutterBinaryMessenger` associated with this FlutterViewController (used for communicating
|
||||||
|
@ -153,7 +153,6 @@ typedef struct MouseState {
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation FlutterViewController {
|
@implementation FlutterViewController {
|
||||||
FlutterEngine* _engine;
|
|
||||||
flutter::ViewportMetrics _viewportMetrics;
|
flutter::ViewportMetrics _viewportMetrics;
|
||||||
MouseState _mouseState;
|
MouseState _mouseState;
|
||||||
}
|
}
|
||||||
@ -302,10 +301,6 @@ typedef struct MouseState {
|
|||||||
[self setUpNotificationCenterObservers];
|
[self setUpNotificationCenterObservers];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (FlutterEngine*)engine {
|
|
||||||
return _engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setUpNotificationCenterObservers {
|
- (void)setUpNotificationCenterObservers {
|
||||||
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
|
||||||
[center addObserver:self
|
[center addObserver:self
|
||||||
|
Loading…
x
Reference in New Issue
Block a user