fix: PlatformColor crashes on iOS and Android (#1703)

Follow-up PR to https://github.com/react-native-svg/react-native-svg/pull/1561 fixing the problems mentioned there. Also fixing the wrong releasing introduced in https://github.com/react-native-svg/react-native-svg/commit/027b8c16aa99267467b5aef0fcfd1aa8c2c8582a
This commit is contained in:
Wojciech Lewicki
2022-02-24 12:53:04 +01:00
committed by GitHub
parent d35878bacc
commit b007efe23a
10 changed files with 525 additions and 706 deletions
+4 -11
View File
@@ -65,31 +65,24 @@ static CGFloat RNSVGTSpan_radToDeg = 180 / (CGFloat)M_PI;
if (self.content) {
RNSVGGlyphContext* gc = [self.textRoot getGlyphContext];
if (self.inlineSize != nil && self.inlineSize.value != 0) {
CGColorRef color;
if (self.fill) {
if (self.fill.class == RNSVGBrush.class) {
color = [self.tintColor CGColor];
CGColorRef color = [self.tintColor CGColor];
[self drawWrappedText:context gc:gc rect:rect color:color];
} else {
color = [self.fill getColorWithOpacity:self.fillOpacity];
CGColorRef color = [self.fill getColorWithOpacity:self.fillOpacity];
[self drawWrappedText:context gc:gc rect:rect color:color];
}
if (color) {
CGColorRelease(color);
color = nil;
}
}
if (self.stroke) {
if (self.stroke.class == RNSVGBrush.class) {
color = [self.tintColor CGColor];
CGColorRef color = [self.tintColor CGColor];
[self drawWrappedText:context gc:gc rect:rect color:color];
} else {
color = [self.stroke getColorWithOpacity:self.strokeOpacity];
CGColorRef color = [self.stroke getColorWithOpacity:self.strokeOpacity];
[self drawWrappedText:context gc:gc rect:rect color:color];
}
if (color) {
CGColorRelease(color);
color = nil;
}
}
} else {