Skip to content

Commit

Permalink
[iOS] Fixes text input plugin crash (flutter#20127)
Browse files Browse the repository at this point in the history
  • Loading branch information
LongCatIsLooong committed Jul 30, 2020
1 parent e9334c9 commit f2b02d8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Expand Up @@ -387,8 +387,8 @@ - (void)dealloc {
}

- (UITextField*)textField {
if (_textField == nil) {
_textField = [[[UITextField alloc] init] autorelease];
if (!_textField) {
_textField = [[UITextField alloc] init];
}
return _textField;
}
Expand Down
Expand Up @@ -17,6 +17,10 @@ - (void)setTextInputState:(NSDictionary*)state;
- (BOOL)isVisibleToAutofill;
@end

@interface FlutterSecureTextInputView : FlutterTextInputView
@property(nonatomic, strong) UITextField* textField;
@end

@interface FlutterTextInputPlugin ()
@property(nonatomic, strong) FlutterTextInputView* reusableInputView;
@property(nonatomic, assign) FlutterTextInputView* activeView;
Expand Down Expand Up @@ -496,4 +500,15 @@ - (void)testUITextInputCallsUpdateEditingStateOnce {
[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

0 comments on commit f2b02d8

Please sign in to comment.