Skip to content

Commit e9be397

Browse files
zhongwuzwcbracken
authored andcommitted
Fixes oc leaks in platform plugin (flutter#15041)
Some objc objects are not released in the iOS embedder. This fixes a subset of those leaks in FlutterPlatformPlugin.mm.
1 parent 75c59c4 commit e9be397

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,16 @@ - (void)vibrateHapticFeedback:(NSString*)feedbackType {
108108

109109
if (@available(iOS 10, *)) {
110110
if ([@"HapticFeedbackType.lightImpact" isEqualToString:feedbackType]) {
111-
[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] impactOccurred];
111+
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] autorelease]
112+
impactOccurred];
112113
} else if ([@"HapticFeedbackType.mediumImpact" isEqualToString:feedbackType]) {
113-
[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium]
114+
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] autorelease]
114115
impactOccurred];
115116
} else if ([@"HapticFeedbackType.heavyImpact" isEqualToString:feedbackType]) {
116-
[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] impactOccurred];
117+
[[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] autorelease]
118+
impactOccurred];
117119
} else if ([@"HapticFeedbackType.selectionClick" isEqualToString:feedbackType]) {
118-
[[[UISelectionFeedbackGenerator alloc] init] selectionChanged];
120+
[[[[UISelectionFeedbackGenerator alloc] init] autorelease] selectionChanged];
119121
}
120122
}
121123
}

0 commit comments

Comments
 (0)