From cf8b9d5e1a261164fe7124dc6dbfe575e7a43b10 Mon Sep 17 00:00:00 2001 From: Wu Zhong Date: Fri, 24 Jan 2020 08:32:31 +0800 Subject: [PATCH] Fixes oc leaks in platform plugin (flutter/engine#15041) 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/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index aaf05854ea..809c467a4e 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -108,14 +108,16 @@ using namespace flutter; 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]; } } }