Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Fixes Objective-C objects memory leaks #14326

Merged
merged 6 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@
// 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++;
Expand Down Expand Up @@ -467,8 +467,7 @@
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);
Expand All @@ -493,7 +492,7 @@
}
auto contentsScale = flutter_view_.get().layer.contentsScale;
fml::scoped_nsobject<FlutterOverlayView> overlay_view(
[[[FlutterOverlayView alloc] initWithContentsScale:contentsScale] retain]);
[[FlutterOverlayView alloc] initWithContentsScale:contentsScale]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

overlay_view.get().frame = flutter_view_.get().bounds;
overlay_view.get().autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ + (CGRect)getCGRectFromSkRect:(const SkRect&)clipSkRect {
- (void)clipRect:(const SkRect&)clipSkRect {
CGRect clipRect = [ChildClippingView getCGRectFromSkRect:clipSkRect];
CGPathRef pathRef = CGPathCreateWithRect(clipRect, nil);
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
clip.path = pathRef;
self.layer.mask = clip;
fml::scoped_nsobject<CAShapeLayer> clip([[CAShapeLayer alloc] init]);
clip.get().path = pathRef;
self.layer.mask = clip.get();
CGPathRelease(pathRef);
}

Expand Down Expand Up @@ -125,9 +125,9 @@ - (void)clipRRect:(const SkRRect&)clipSkRRect {
// 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];
clip.path = pathRef;
self.layer.mask = clip;
fml::scoped_nsobject<CAShapeLayer> clip([[CAShapeLayer alloc] init]);
clip.get().path = pathRef;
self.layer.mask = clip.get();
CGPathRelease(pathRef);
}

Expand All @@ -137,9 +137,9 @@ - (void)clipPath:(const SkPath&)path {
return;
}
if (path.isEmpty()) {
CAShapeLayer* clip = [[CAShapeLayer alloc] init];
clip.path = pathRef;
self.layer.mask = clip;
fml::scoped_nsobject<CAShapeLayer> clip([[CAShapeLayer alloc] init]);
clip.get().path = pathRef;
self.layer.mask = clip.get();
CGPathRelease(pathRef);
return;
}
Expand Down Expand Up @@ -195,9 +195,9 @@ - (void)clipPath:(const SkPath&)path {
verb = iter.next(pts);
}

CAShapeLayer* clip = [[CAShapeLayer alloc] init];
clip.path = pathRef;
self.layer.mask = clip;
fml::scoped_nsobject<CAShapeLayer> clip([[CAShapeLayer alloc] init]);
clip.get().path = pathRef;
self.layer.mask = clip.get();
CGPathRelease(pathRef);
}

Expand Down