JESCircularProgressView
JESCircularProgressView copied to clipboard
CGPath errors
Hi,
I discovered that everytime my app starts I get a lot of warnings:
<Error>: Error: this application, or a library it uses, has passed an invalid numeric value (NaN, or not-a-number) to CoreGraphics API and this value is being ignored.Please fix this problem.
<Error>: void CGPathCloseSubpath(CGMutablePathRef _Nullable): no current point.
After some debugging it appeared that some of the items you compute (center, etc) are invalid when the bounds
property is empty. By adding a check on self.bounds in the method bellow I was able to prevent these messages. Maybe a better check could be to reset progressLineInset
to CGRectZero
if CGRectIsInfinite
returns YES
; that way if the bounds are not empty but not big enough for the line widths it would still prevent those errors.
- (CGRect)progressLineInset {
static CGRect progressLineInset;
if (CGRectIsEmpty(self.bounds))
return CGRectZero;
if (CGRectIsEmpty(progressLineInset)) {
progressLineInset = CGRectIntegral(CGRectInset(self.bounds,
round(self.progressLineWidth + self.outerLineWidth),
round(self.progressLineWidth + self.outerLineWidth)));
}
return progressLineInset;
}
Thanks for considering!
I just tried with CGRectIsInfinite
, it doesn't work because in my case it's the rect origin that is wrong. Using those lines seems to work though
if (!isnormal(progressLineInset.origin.x) ||
!isnormal(progressLineInset.origin.y) ||
!isnormal(progressLineInset.size.width) ||
!isnormal(progressLineInset.size.height))
{
progressLineInset = CGRectZero;
}
Thanks @dvkch! I would love a pull request with those fixes if you wouldn't mind! Otherwise I'll try to get to it ASAP