Re: NSBezierPath EXC_BAD_ACCESS issues.
Re: NSBezierPath EXC_BAD_ACCESS issues.
- Subject: Re: NSBezierPath EXC_BAD_ACCESS issues.
- From: Graham Cox <email@hidden>
- Date: Wed, 3 Mar 2010 23:48:10 +1100
Your setBezierPath method is making a new, autoreleased path, it isn't using the one you created at initialisation. That is then autoreleased leaving <path> stale, hence the crash. You're also leaking the first path you made.
If setBezierPath is there to simply set up the bezier path, it shouldn't make another path, you already made it, but also it shouldn't be named set...<Something> as it's not setting anything. Call it initialiseBezierPath for example.
--Graham
On 03/03/2010, at 11:34 PM, Billy Flatman wrote:
> Hi all,
>
> I have a shape class containing an
>
> attribute:
> NSBezierPath *path;
>
> initialisation:
> path = [[NSBezierPath alloc] init];
> [self setBezierPath];
>
> setBezierPath:
> path = [NSBezierPath bezierPath];
> then add the paths and close path.
>
> paint:
> [path setLineWidth: 1];
> [path fill];
>
> It all worked well when I had the setBezierPath method called from paint, but since only calling setBezierPath in an update method and during initialisation, I've started getting a exc_bad_access exception when path is called in the paint method.
>
> Any help would be greatly appreciated.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden