From 8461fab6a7ffd7cda38b5211819f363427f7c66d Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 29 Jul 2020 15:00:33 -0700 Subject: [PATCH 1/3] fixes crash --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index a135c4fcc7f19..e619185cee38c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -374,7 +374,7 @@ - (BOOL)isEqualTo:(FlutterTextRange*)other { // currently only support UITextFields, and password saving only supports // UITextFields and UITextViews, as of iOS 13.5. @interface FlutterSecureTextInputView : FlutterTextInputView -@property(nonatomic, strong, readonly) UITextField* textField; +@property(nonatomic, strong) UITextField* textField; @end @implementation FlutterSecureTextInputView { @@ -387,8 +387,8 @@ - (void)dealloc { } - (UITextField*)textField { - if (_textField == nil) { - _textField = [[[UITextField alloc] init] autorelease]; + if (!_textField) { + _textField = [[UITextField alloc] init]; } return _textField; } From 015d3b90fc9dbf901ec4d3ee962dca6fa500dd7e Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 29 Jul 2020 15:12:18 -0700 Subject: [PATCH 2/3] add test --- .../framework/Source/FlutterTextInputPluginTest.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m index 21b1d1cf5ae36..7f69a19664de1 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -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; @@ -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 From 0fed0453d73f1437fae4848068a80c248d27f444 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 29 Jul 2020 15:17:50 -0700 Subject: [PATCH 3/3] makes it readonly again --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index e619185cee38c..1e04170da2159 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -374,7 +374,7 @@ - (BOOL)isEqualTo:(FlutterTextRange*)other { // currently only support UITextFields, and password saving only supports // UITextFields and UITextViews, as of iOS 13.5. @interface FlutterSecureTextInputView : FlutterTextInputView -@property(nonatomic, strong) UITextField* textField; +@property(nonatomic, strong, readonly) UITextField* textField; @end @implementation FlutterSecureTextInputView {