Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash Issue in _expand function for using only one AwsomeMenu item #48

Open
vksmaini opened this issue Dec 5, 2013 · 5 comments
Open

Comments

@vksmaini
Copy link

vksmaini commented Dec 5, 2013

Assertion failed: (CGFloatIsValid(x) && CGFloatIsValid(y)), function void CGPathAddLineToPoint(CGMutablePathRef, const CGAffineTransform *, CGFloat, CGFloat), file Paths/CGPath.cc

@vksmaini
Copy link
Author

Is anybody there who can explain this to me?

@dbayon
Copy link

dbayon commented Jan 22, 2014

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.

@vksmaini
Copy link
Author

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//issues/48#issuecomment-33007094
.

Regards --
Vikas Maini
http://about.me/vikasmaini

@levey levey closed this as completed Feb 26, 2015
@SeanWangDev
Copy link

Mate, it is still happening. Would you please fix this?

@levey levey reopened this Mar 6, 2015
@monkiyang
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants