[darwin] Fixes CGImageRef leak when creating a map snapshot (#10585)

This commit is contained in:
Andrew Kitchen
2017-11-28 14:51:30 -08:00
committed by GitHub
parent 09b97e037c
commit c178bd2d25

View File

@@ -321,14 +321,18 @@ const CGFloat MGLSnapshotterMinimumPixelSize = 64;
CIContext *ctx = [CIContext contextWithOptions:nil];
CGImageRef cgimg = [ctx createCGImage:blurredImage fromRect:[backgroundImage extent]];
MGLImage *image;
#if TARGET_OS_IPHONE
return [UIImage imageWithCGImage:cgimg];
image = [UIImage imageWithCGImage:cgimg];
#else
return [[NSImage alloc] initWithCGImage:cgimg size:[backgroundImage extent].size];
image = [[NSImage alloc] initWithCGImage:cgimg size:[backgroundImage extent].size];
#endif
CGImageRelease(cgimg);
return image;
}
- (void)cancel