mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-05-24 11:44:39 +00:00
Fix memory leaks
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user