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

Ribbon is causing NSRangeException #228

Closed
GoogleCodeExporter opened this issue Jul 23, 2015 · 4 comments
Closed

Ribbon is causing NSRangeException #228

GoogleCodeExporter opened this issue Jul 23, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Use Motion streak for some time.
2. After a while the application terminates itself with an error 
"Terminating app due to uncaught exception 'NSRangeException', reason: '***
-[NSCFArray objectAtIndex:]: index (-1( or possibly larger)) beyond bounds
(0)'"

What cocos2d version are you using ?
Latest

What iPhoneSDK are you using ?
2.1

Debug or Release ?
Both

Does this happen on device ? or on the simulator ? or on both ?
Both

Please provide any additional information below.
in Ribbon.m in function
-(void)addPointAt:(cpVect)location width:(float)w

this:
  RibbonSegment* seg;
  // first lets kill old segments
  for (seg in mSegments)
  {
    if (seg->finished)
    {
      [dSegments addObject:seg];
    }
  }
  [mSegments removeObjectsInArray:dSegments];
  // grab last segment and appent to it if it's not full
  seg = [mSegments objectAtIndex:[mSegments count]-1];
  // is the segment full?
  if (seg->end >= 50)
  {

should be changed to this:
    RibbonSegment* seg;
    // grab last segment
    seg = [mSegments objectAtIndex:[mSegments count]-1];
    // lets kill old segments
    for (RibbonSegment* seg2 in mSegments)
    {
        if (seg2 != seg && seg2->finished)
        {
            [dSegments addObject:seg2];
        }
    }
    [mSegments removeObjectsInArray:dSegments];
    // is the segment full?
    if (seg->end >= 50)

What's wrong:
When ALL segments have finished
    [mSegments removeObjectsInArray:dSegments];
will delete all segments from mSegments. And
  seg = [mSegments objectAtIndex:[mSegments count]-1];
will fail because mSegments will be empty. This patch is making sure that
there is at least one segment left in mSegment.

Original issue reported on code.google.com by kermidt....@gmail.com on 28 Feb 2009 at 9:42

@GoogleCodeExporter
Copy link
Author

Original comment by ricardoq...@gmail.com on 28 Feb 2009 at 12:49

@GoogleCodeExporter
Copy link
Author

nice find, do you want me to make this change and check it in riq?

Original comment by slipster...@gmail.com on 28 Feb 2009 at 1:47

@GoogleCodeExporter
Copy link
Author

yes, please. thanks.

Original comment by ricardoq...@gmail.com on 28 Feb 2009 at 1:49

@GoogleCodeExporter
Copy link
Author

fixed..

Original comment by slipster...@gmail.com on 28 Feb 2009 at 5:25

  • Changed state: Fixed

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

No branches or pull requests

1 participant