3
3
// found in the LICENSE file.
4
4
5
5
#import " flutter/shell/platform/darwin/ios/framework/Source/FlutterKeyboardManager.h"
6
+
6
7
#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
8
11
9
12
static constexpr CFTimeInterval kDistantFuture = 1.0e10 ;
10
13
@@ -28,16 +31,13 @@ - (void)dispatchToSecondaryResponders:(nonnull FlutterUIPressProxy*)press
28
31
29
32
@end
30
33
31
- @implementation FlutterKeyboardManager {
32
- std::unique_ptr<fml::WeakNSObjectFactory<FlutterKeyboardManager>> _weakFactory;
33
- }
34
+ @implementation FlutterKeyboardManager
34
35
35
36
- (nonnull instancetype )init {
36
37
self = [super init ];
37
38
if (self != nil ) {
38
39
_primaryResponders = [[NSMutableArray alloc ] init ];
39
40
_secondaryResponders = [[NSMutableArray alloc ] init ];
40
- _weakFactory = std::make_unique<fml::WeakNSObjectFactory<FlutterKeyboardManager>>(self);
41
41
}
42
42
return self;
43
43
}
@@ -51,21 +51,8 @@ - (void)addSecondaryResponder:(nonnull id<FlutterKeySecondaryResponder>)responde
51
51
}
52
52
53
53
- (void )dealloc {
54
- // It will be destroyed and invalidate its weak pointers
55
- // before any other members are destroyed.
56
- _weakFactory.reset ();
57
-
58
54
[_primaryResponders removeAllObjects ];
59
55
[_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 ();
69
56
}
70
57
71
58
- (void )handlePress : (nonnull FlutterUIPressProxy*)press
@@ -89,7 +76,7 @@ - (void)handlePress:(nonnull FlutterUIPressProxy*)press
89
76
// encounter.
90
77
NSAssert ([_primaryResponders count ] >= 0 , @" At least one primary responder must be added." );
91
78
92
- __block auto weakSelf = [ self getWeakNSObject ] ;
79
+ __block __weak __typeof (self) weakSelf = self;
93
80
__block NSUInteger unreplied = [self .primaryResponders count ];
94
81
__block BOOL anyHandled = false ;
95
82
FlutterAsyncKeyCallback replyCallback = ^(BOOL handled) {
@@ -98,7 +85,7 @@ - (void)handlePress:(nonnull FlutterUIPressProxy*)press
98
85
anyHandled = anyHandled || handled;
99
86
if (unreplied == 0 ) {
100
87
if (!anyHandled && weakSelf) {
101
- [weakSelf. get () dispatchToSecondaryResponders: press complete: completeCallback];
88
+ [weakSelf dispatchToSecondaryResponders: press complete: completeCallback];
102
89
} else {
103
90
completeCallback (true , press);
104
91
}
0 commit comments