diff --git a/ios/Elements/RNSVGImage.m b/ios/Elements/RNSVGImage.m index efd87231..30b6b06b 100644 --- a/ios/Elements/RNSVGImage.m +++ b/ios/Elements/RNSVGImage.m @@ -94,7 +94,9 @@ { CGRect rect = [self getRect:context]; // add hit area - self.hitArea = CGPathCreateWithRect(rect, nil); + CGPathRef hitArea = CGPathCreateWithRect(rect, nil); + [self setHitArea:hitArea]; + CGPathRelease(hitArea); [self clip:context]; CGContextSaveGState(context); diff --git a/ios/RNSVGRenderable.m b/ios/RNSVGRenderable.m index e7c6b138..47bb921b 100644 --- a/ios/RNSVGRenderable.m +++ b/ios/RNSVGRenderable.m @@ -252,7 +252,7 @@ CGPathRelease(strokePath); } - _hitArea = CGPathRetain(CGPathCreateCopy(hitArea)); + _hitArea = CGPathRetain(CFAutorelease(CGPathCreateCopy(hitArea))); CGPathRelease(hitArea); } diff --git a/ios/Text/RNSVGTSpan.m b/ios/Text/RNSVGTSpan.m index 1536d3dd..ee3f2b34 100644 --- a/ios/Text/RNSVGTSpan.m +++ b/ios/Text/RNSVGTSpan.m @@ -34,6 +34,11 @@ _cache = nil; } +- (void)dealloc +{ + CGPathRelease(_cache); +} + - (CGPathRef)getPath:(CGContextRef)context { if (_cache) { @@ -69,14 +74,14 @@ CGMutablePathRef linePath = [self getLinePath:line]; CGAffineTransform offset = CGAffineTransformMakeTranslation(0, _bezierTransformer ? 0 : CTFontGetSize(font) * 1.1); CGPathAddPath(path, &offset, linePath); + CGPathRelease(linePath); - _cache = CGPathRetain(CGPathCreateCopy(path)); + _cache = CGPathRetain(CFAutorelease(CGPathCreateCopy(path))); [self popGlyphContext]; // clean up CFRelease(attrString); CFRelease(line); - CGPathRelease(linePath); return (CGPathRef)CFAutorelease(path); } diff --git a/ios/Text/RNSVGText.m b/ios/Text/RNSVGText.m index 43f4411b..de9e7b0b 100644 --- a/ios/Text/RNSVGText.m +++ b/ios/Text/RNSVGText.m @@ -29,15 +29,18 @@ [self clip:context]; CGContextSaveGState(context); [self setupGlyphContext:context]; - CGPathRef path = [self getPath:context]; + CGPathRef path = [self getGroupPath:context]; CGAffineTransform transform = [self getAlignTransform:context path:path]; CGContextConcatCTM(context, transform); - - [self setHitArea:path]; [self renderGroupTo:context]; [self releaseCachedPath]; CGContextRestoreGState(context); + + + CGPathRef transformedPath = CGPathCreateCopyByTransformingPath(path, &transform); + [self setHitArea:transformedPath]; + CGPathRelease(transformedPath); } - (void)setupGlyphContext:(CGContextRef)context @@ -71,10 +74,9 @@ [self setupGlyphContext:context]; CGPathRef groupPath = [self getGroupPath:context]; CGAffineTransform transform = [self getAlignTransform:context path:groupPath]; - CGPathRef transformedPath = CGPathCreateCopyByTransformingPath(groupPath, &transform); [self releaseCachedPath]; - return transformedPath; + return (CGPathRef)CFAutorelease(CGPathCreateCopyByTransformingPath(groupPath, &transform)); } - (void)renderGroupTo:(CGContextRef)context