33// found in the LICENSE file.
44
55#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.h"
6+
67#include " flutter/fml/platform/darwin/message_loop_darwin.h"
7- #include " flutter/fml/platform/darwin/weak_nsobject.h"
8+ #import " flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
9+
10+ FLUTTER_ASSERT_ARC
811
912static constexpr CFTimeInterval kDistantFuture = 1.0e10 ;
1013
@@ -28,16 +31,13 @@ - (void)dispatchToSecondaryResponders:(nonnull FlutterUIPressProxy*)press
2831
2932@end
3033
31- @implementation FlutterKeyboardManager {
32- std::unique_ptr<fml::WeakNSObjectFactory<FlutterKeyboardManager>> _weakFactory;
33- }
34+ @implementation FlutterKeyboardManager
3435
3536- (nonnull instancetype )init {
3637 self = [super init ];
3738 if (self != nil ) {
3839 _primaryResponders = [[NSMutableArray alloc ] init ];
3940 _secondaryResponders = [[NSMutableArray alloc ] init ];
40- _weakFactory = std::make_unique<fml::WeakNSObjectFactory<FlutterKeyboardManager>>(self);
4141 }
4242 return self;
4343}
@@ -51,21 +51,8 @@ - (void)addSecondaryResponder:(nonnull id<FlutterKeySecondaryResponder>)responde
5151}
5252
5353- (void )dealloc {
54- // It will be destroyed and invalidate its weak pointers
55- // before any other members are destroyed.
56- _weakFactory.reset ();
57-
5854 [_primaryResponders removeAllObjects ];
5955 [_secondaryResponders removeAllObjects ];
60- [_primaryResponders release ];
61- [_secondaryResponders release ];
62- _primaryResponders = nil ;
63- _secondaryResponders = nil ;
64- [super dealloc ];
65- }
66-
67- - (fml::WeakNSObject<FlutterKeyboardManager>)getWeakNSObject {
68- return _weakFactory->GetWeakNSObject ();
6956}
7057
7158- (void )handlePress : (nonnull FlutterUIPressProxy*)press
@@ -89,7 +76,7 @@ - (void)handlePress:(nonnull FlutterUIPressProxy*)press
8976 // encounter.
9077 NSAssert ([_primaryResponders count ] >= 0 , @" At least one primary responder must be added." );
9178
92- __block auto weakSelf = [ self getWeakNSObject ] ;
79+ __block __weak __typeof (self) weakSelf = self;
9380 __block NSUInteger unreplied = [self .primaryResponders count ];
9481 __block BOOL anyHandled = false ;
9582 FlutterAsyncKeyCallback replyCallback = ^(BOOL handled) {
@@ -98,7 +85,7 @@ - (void)handlePress:(nonnull FlutterUIPressProxy*)press
9885 anyHandled = anyHandled || handled;
9986 if (unreplied == 0 ) {
10087 if (!anyHandled && weakSelf) {
101- [weakSelf. get () dispatchToSecondaryResponders: press complete: completeCallback];
88+ [weakSelf dispatchToSecondaryResponders: press complete: completeCallback];
10289 } else {
10390 completeCallback (true , press);
10491 }
0 commit comments