[iOS] Fixes text input plugin crash (flutter/engine#20127)

This commit is contained in:
LongCatIsLooong
2020-07-30 11:32:49 -07:00
committed by GitHub
parent fb4de3e0f6
commit f522de0d27
2 changed files with 17 additions and 2 deletions

View File

@@ -387,8 +387,8 @@ static FlutterAutofillType autofillTypeOf(NSDictionary* configuration) {
}
- (UITextField*)textField {
if (_textField == nil) {
_textField = [[[UITextField alloc] init] autorelease];
if (!_textField) {
_textField = [[UITextField alloc] init];
}
return _textField;
}

View File

@@ -17,6 +17,10 @@ FLUTTER_ASSERT_ARC
- (BOOL)isVisibleToAutofill;
@end
@interface FlutterSecureTextInputView : FlutterTextInputView
@property(nonatomic, strong) UITextField* textField;
@end
@interface FlutterTextInputPlugin ()
@property(nonatomic, strong) FlutterTextInputView* reusableInputView;
@property(nonatomic, assign) FlutterTextInputView* activeView;
@@ -496,4 +500,15 @@ FLUTTER_ASSERT_ARC
[inputView unmarkText];
XCTAssertEqual(updateCount, 6);
}
- (void)testNoZombies {
// Regression test for https://github.com/flutter/flutter/issues/62501.
FlutterSecureTextInputView* passwordView = [[FlutterSecureTextInputView alloc] init];
@autoreleasepool {
// Initialize the lazy textField.
[passwordView.textField description];
}
XCTAssert([[passwordView.textField description] containsString:@"TextField"]);
}
@end