mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-02 23:02:16 +00:00
Fix memory leaks in iOS
Fix memory leaks in iOS and do not render stroke if strokeWidth is undefined
This commit is contained in:
@@ -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;
|
||||
}];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user