Re: Problem on clearing points and paths on a NSView
Re: Problem on clearing points and paths on a NSView
- Subject: Re: Problem on clearing points and paths on a NSView
- From: Jens Alfke <email@hidden>
- Date: Tue, 22 Jul 2008 21:06:23 -0700
On 22 Jul '08, at 6:45 PM, JArod Wen wrote:
Now I am considering the possible memory leakage in renderPath,
since each time the path will be initialized and the previous one
will cause memory leakage, which may be also the reason why I cannot
get rid of them from the view. But if so, how about the renderPoint?
It seems ok but still cannot be removed...
-renderPath does have memory leaks (unless you've turned on garbage
collection) because it allocs pathPoint but never releases it. You
just need to add a single [pathPoint release] at the end of that
block. (Or just use [NSBezierPath bezierPathWithOvalInRect:], which is
an easier way to create a circle and doesn't require you to release
the result.)
As Graham pointed out, the reason your shapes don't get erased is that
you don't erase them. Your -drawRect method needs to begin by clearing
the passed-in NSRect to the background color, otherwise you may be
leaving behind the old contents of the view.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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