From 8203e43279d053f385dc65efdde8c5854545014d Mon Sep 17 00:00:00 2001 From: zhongwuzw Date: Mon, 30 Dec 2019 16:35:30 +0800 Subject: [PATCH] Fixes oc leaks in platform plugin Some objc objects are not released in the iOS embedder. This fixes a subset of those leaks in FlutterPlatformPlugin.mm. --- .../ios/framework/Source/FlutterPlatformPlugin.mm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index aaf05854eaa18..809c467a4e554 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -108,14 +108,16 @@ - (void)vibrateHapticFeedback:(NSString*)feedbackType { if (@available(iOS 10, *)) { if ([@"HapticFeedbackType.lightImpact" isEqualToString:feedbackType]) { - [[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] impactOccurred]; + [[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight] autorelease] + impactOccurred]; } else if ([@"HapticFeedbackType.mediumImpact" isEqualToString:feedbackType]) { - [[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] + [[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleMedium] autorelease] impactOccurred]; } else if ([@"HapticFeedbackType.heavyImpact" isEqualToString:feedbackType]) { - [[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] impactOccurred]; + [[[[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleHeavy] autorelease] + impactOccurred]; } else if ([@"HapticFeedbackType.selectionClick" isEqualToString:feedbackType]) { - [[[UISelectionFeedbackGenerator alloc] init] selectionChanged]; + [[[[UISelectionFeedbackGenerator alloc] init] autorelease] selectionChanged]; } } }