Fixes FlutterEngine internal retain cycle (flutter/engine#18595)
This commit is contained in:
@@ -396,17 +396,22 @@ static constexpr int kNumProfilerSamplesPerSec = 5;
|
||||
|
||||
- (void)maybeSetupPlatformViewChannels {
|
||||
if (_shell && self.shell.IsSetup()) {
|
||||
FlutterPlatformPlugin* platformPlugin = _platformPlugin.get();
|
||||
[_platformChannel.get() setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
|
||||
[_platformPlugin.get() handleMethodCall:call result:result];
|
||||
[platformPlugin handleMethodCall:call result:result];
|
||||
}];
|
||||
|
||||
fml::WeakPtr<FlutterEngine> weakSelf = [self getWeakPtr];
|
||||
[_platformViewsChannel.get()
|
||||
setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
|
||||
_platformViewsController->OnMethodCall(call, result);
|
||||
if (weakSelf) {
|
||||
weakSelf.get().platformViewsController->OnMethodCall(call, result);
|
||||
}
|
||||
}];
|
||||
|
||||
FlutterTextInputPlugin* textInputPlugin = _textInputPlugin.get();
|
||||
[_textInputChannel.get() setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
|
||||
[_textInputPlugin.get() handleMethodCall:call result:result];
|
||||
[textInputPlugin handleMethodCall:call result:result];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
|
||||
FLUTTER_ASSERT_ARC
|
||||
|
||||
@interface FlutteEngineTest : XCTestCase
|
||||
@interface FlutterEngineTest : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation FlutteEngineTest
|
||||
@implementation FlutterEngineTest
|
||||
|
||||
- (void)setUp {
|
||||
}
|
||||
@@ -26,6 +26,17 @@ FLUTTER_ASSERT_ARC
|
||||
XCTAssertNotNil(engine);
|
||||
}
|
||||
|
||||
- (void)testDeallocated {
|
||||
__weak FlutterEngine* weakEngine = nil;
|
||||
{
|
||||
FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
|
||||
weakEngine = engine;
|
||||
[engine run];
|
||||
XCTAssertNotNil(weakEngine);
|
||||
}
|
||||
XCTAssertNil(weakEngine);
|
||||
}
|
||||
|
||||
- (void)testSendMessageBeforeRun {
|
||||
id project = OCMClassMock([FlutterDartProject class]);
|
||||
FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project];
|
||||
|
||||
Reference in New Issue
Block a user