提交 9c1bd8ae 编写于 作者: W Wu Zhong 提交者: Chris Bracken

Fixes Objective-C objects memory leaks (#14326)

Fixes CALayer memory leaks in file FlutterPlatformViews_Internal.mm,FlutterPlatformViews.mm

flutter/flutter#46750
上级 dda3619a
......@@ -253,7 +253,7 @@ UIView* FlutterPlatformViewsController::ReconstructClipViewsChain(int number_of_
// If there were not enough existing clip views, add more.
while (clipIndex < number_of_clips) {
ChildClippingView* clippingView =
[[ChildClippingView alloc] initWithFrame:flutter_view_.get().bounds];
[[[ChildClippingView alloc] initWithFrame:flutter_view_.get().bounds] autorelease];
[clippingView addSubview:head];
head = clippingView;
clipIndex++;
......@@ -467,8 +467,7 @@ void FlutterPlatformViewsController::EnsureOverlayInitialized(
if (overlays_.count(overlay_id) != 0) {
return;
}
fml::scoped_nsobject<FlutterOverlayView> overlay_view(
[[[FlutterOverlayView alloc] init] retain]);
fml::scoped_nsobject<FlutterOverlayView> overlay_view([[FlutterOverlayView alloc] init]);
overlay_view.get().frame = flutter_view_.get().bounds;
overlay_view.get().autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
......@@ -493,7 +492,7 @@ void FlutterPlatformViewsController::EnsureOverlayInitialized(
}
auto contentsScale = flutter_view_.get().layer.contentsScale;
fml::scoped_nsobject<FlutterOverlayView> overlay_view(
[[[FlutterOverlayView alloc] initWithContentsScale:contentsScale] retain]);
[[FlutterOverlayView alloc] initWithContentsScale:contentsScale]);
overlay_view.get().frame = flutter_view_.get().bounds;
overlay_view.get().autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
......
......@@ -56,11 +56,10 @@ void ResetAnchor(CALayer* layer) {
- (void)clipRect:(const SkRect&)clipSkRect {
CGRect clipRect = [ChildClippingView getCGRectFromSkRect:clipSkRect];
CGPathRef pathRef = CGPathCreateWithRect(clipRect, nil);
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
fml::CFRef<CGPathRef> pathRef(CGPathCreateWithRect(clipRect, nil));
CAShapeLayer* clip = [[[CAShapeLayer alloc] init] autorelease];
clip.path = pathRef;
self.layer.mask = clip;
CGPathRelease(pathRef);
}
- (void)clipRRect:(const SkRRect&)clipSkRRect {
......@@ -126,7 +125,7 @@ void ResetAnchor(CALayer* layer) {
// TODO(cyanglaz): iOS does not seem to support hard edge on CAShapeLayer. It clearly stated that
// the CAShaperLayer will be drawn antialiased. Need to figure out a way to do the hard edge
// clipping on iOS.
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
CAShapeLayer* clip = [[[CAShapeLayer alloc] init] autorelease];
clip.path = pathRef;
self.layer.mask = clip;
CGPathRelease(pathRef);
......@@ -138,7 +137,7 @@ void ResetAnchor(CALayer* layer) {
}
fml::CFRef<CGMutablePathRef> pathRef(CGPathCreateMutable());
if (path.isEmpty()) {
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
CAShapeLayer* clip = [[[CAShapeLayer alloc] init] autorelease];
clip.path = pathRef;
self.layer.mask = clip;
return;
......@@ -195,7 +194,7 @@ void ResetAnchor(CALayer* layer) {
verb = iter.next(pts);
}
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
CAShapeLayer* clip = [[[CAShapeLayer alloc] init] autorelease];
clip.path = pathRef;
self.layer.mask = clip;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册