[iOS] Fixes text input plugin crash (flutter/engine#20127)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user