Fix memory leaks in iOS

Fix memory leaks in iOS and do not render stroke if strokeWidth is
undefined
This commit is contained in:
Horcrux
2017-01-08 17:08:37 +08:00
parent 152e839126
commit 431b61ce76
7 changed files with 37 additions and 39 deletions
+1 -1
View File
@@ -24,7 +24,7 @@
}];
[self traverseSubviews:^(RNSVGNode *node) {
[node mergeProperties:self mergeList:self.ownedPropList inherited:YES];
[node mergeProperties:self mergeList:self.attributeList inherited:YES];
[node renderTo:context];
return YES;
}];
+4 -5
View File
@@ -29,8 +29,7 @@
- (void)renderLayerTo:(CGContextRef)context
{
// todo: add detection if path has changed since last update.
self.d = [self getPath:context];
CGPathRef path = self.d;
CGPathRef path = [self getPath:context];
if ((!self.fill && !self.stroke) || !path) {
return;
}
@@ -38,14 +37,14 @@
if ([self getSvgView].responsible) {
// Add path to hitArea
CGMutablePathRef hitArea = CGPathCreateMutableCopy(path);
if (self.stroke) {
if (self.stroke && self.strokeWidth) {
// Add stroke to hitArea
CGPathRef strokePath = CGPathCreateCopyByStrokingPath(hitArea, nil, self.strokeWidth, self.strokeLinecap, self.strokeLinejoin, self.strokeMiterlimit);
CGPathAddPath(hitArea, nil, strokePath);
CGPathRelease(strokePath);
}
self.hitArea = CGPathCreateCopy(hitArea);
self.hitArea = CFAutorelease(CGPathCreateCopy(hitArea));
CGPathRelease(hitArea);
}
@@ -75,7 +74,7 @@
}
}
if (self.stroke) {
if (self.stroke && self.strokeWidth) {
CGContextSetLineWidth(context, self.strokeWidth);
CGContextSetLineCap(context, self.strokeLinecap);
CGContextSetLineJoin(context, self.strokeLinejoin);
+1 -1
View File
@@ -27,7 +27,7 @@
if (template) {
[self beginTransparencyLayer:context];
[self clip:context];
[template mergeProperties:self mergeList:self.ownedPropList];
[template mergeProperties:self mergeList:self.attributeList inherited:YES];
[template renderTo:context];
[template resetProperties];
[self endTransparencyLayer:context];