AwesomeMenu
AwesomeMenu copied to clipboard
Crash Issue in _expand function for using only one AwsomeMenu item
Assertion failed: (CGFloatIsValid(x) && CGFloatIsValid(y)), function void CGPathAddLineToPoint(CGMutablePathRef, const CGAffineTransform *, CGFloat, CGFloat), file Paths/CGPath.cc
Is anybody there who can explain this to me?
It happens to me too. I realized that happens when I´ve got only one menuitem. I quick solve this with:
CGPoint endPoint = CGPointMake(startPoint.x + endRadius * sinf(i * menuWholeAngle / (count - 1)), startPoint.y - endRadius * cosf(i * menuWholeAngle / (count - 1)));
if(isnan(endPoint.x)) endPoint = CGPointZero;
item.endPoint = RotateCGPointAroundCenter(endPoint, startPoint, rotateAngle);
CGPoint nearPoint = CGPointMake(startPoint.x + nearRadius * sinf(i * menuWholeAngle / (count - 1)), startPoint.y - nearRadius * cosf(i * menuWholeAngle / (count - 1)));
if(isnan(nearPoint.x)) nearPoint = CGPointZero;
item.nearPoint = RotateCGPointAroundCenter(nearPoint, startPoint, rotateAngle);
CGPoint farPoint = CGPointMake(startPoint.x + farRadius * sinf(i * menuWholeAngle / (count - 1)), startPoint.y - farRadius * cosf(i * menuWholeAngle / (count - 1)));
if(isnan(farPoint.x)) farPoint = CGPointZero;
item.farPoint = RotateCGPointAroundCenter(farPoint, startPoint, rotateAngle);
In method _setMenu in AwesomeMenu.m
It´s not a valid solution, you must hardcode a good values for your porpouses, or even better, a generalistic solution.
Well yes I hardcoded the values for a single menu item in the end. Anyway thanks for responding.
On Wed, Jan 22, 2014 at 3:25 PM, dbayon [email protected] wrote:
It happens to me too. I realized that happens when I´ve got only one menuitem. I quick solve this with:
CGPoint endPoint = CGPointMake(startPoint.x + endRadius * sinf(i * menuWholeAngle / (count - 1)), startPoint.y - endRadius * cosf(i * menuWholeAngle / (count - 1))); if(isnan(endPoint.x)) endPoint = CGPointZero; item.endPoint = RotateCGPointAroundCenter(endPoint, startPoint, rotateAngle); CGPoint nearPoint = CGPointMake(startPoint.x + nearRadius * sinf(i * menuWholeAngle / (count - 1)), startPoint.y - nearRadius * cosf(i * menuWholeAngle / (count - 1))); if(isnan(nearPoint.x)) nearPoint = CGPointZero; item.nearPoint = RotateCGPointAroundCenter(nearPoint, startPoint, rotateAngle); CGPoint farPoint = CGPointMake(startPoint.x + farRadius * sinf(i * menuWholeAngle / (count - 1)), startPoint.y - farRadius * cosf(i * menuWholeAngle / (count - 1))); if(isnan(farPoint.x)) farPoint = CGPointZero; item.farPoint = RotateCGPointAroundCenter(farPoint, startPoint, rotateAngle);
In method _setMenu in AwesomeMenu.m
It´s not a valid solution, you must hardcode a good values for your porpouses, or even better, a generalistic solution.
— Reply to this email directly or view it on GitHubhttps://github.com/levey/AwesomeMenu/issues/48#issuecomment-33007094 .
Regards -- Vikas Maini http://about.me/vikasmaini
Mate, it is still happening. Would you please fix this?
I debugged, and found that it crashes because the dividend (count-1) is 0. I printed endPoint nearPoint and farPoint are all (x = NaN, y = NaN). When the program uses endPoint.x, It crashes finally. I fix it with:
CGPoint endPoint = CGPointMake(startPoint.x + endRadius * sinf(i * menuWholeAngle / ((count - 1) > 0 ? (count - 1) : 1)), startPoint.y - endRadius * cosf(i * menuWholeAngle / ((count - 1) > 0 ? (count - 1) : 1)) - self.itemDistance * (count - i));
item.endPoint = RotateCGPointAroundCenter(endPoint, startPoint, rotateAngle);
CGPoint nearPoint = CGPointMake(startPoint.x + nearRadius * sinf(i * menuWholeAngle / ((count - 1) > 0 ? (count - 1) : 1)), startPoint.y - nearRadius * cosf(i * menuWholeAngle / ((count - 1) > 0 ? (count - 1) : 1)));
item.nearPoint = RotateCGPointAroundCenter(nearPoint, startPoint, rotateAngle);
CGPoint farPoint = CGPointMake(startPoint.x + farRadius * sinf(i * menuWholeAngle / ((count - 1) > 0 ? (count - 1) : 1)), startPoint.y - farRadius * cosf(i * menuWholeAngle / ((count - 1) > 0 ? (count - 1) : 1)));
item.farPoint = RotateCGPointAroundCenter(farPoint, startPoint, rotateAngle);
I guarantee the dividend is not 0 but 1 if there is only 1 menu item. Sorry for my poor english.