• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Crashing View
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Crashing View


  • Subject: Re: Crashing View
  • From: Nick Zitzmann <email@hidden>
  • Date: Sat, 7 Apr 2007 16:18:42 -0600


On Apr 7, 2007, at 4:00 PM, Tom Marchand wrote:

I've got a custom view that has a transparent background created with colorWithDeviceRed. Everything works ok until I resize the window, which results in the app crashing. Any help would be appreciated. Here's the code:

You did not ask a question in your post (that would be helpful next time), so I am assuming your question is "why is this crashing?" If so, then here is your answer:


- (id)initWithFrame:(NSRect)frameRect
{
if ((self = [super initWithFrame:frameRect]) != nil)
{
BackGround=[NSColor colorWithDeviceRed:.50 green:0.50 blue:.50 alpha:.50];

You're creating a temporary object here. It will be deallocated when the autorelease pool is popped. Since resizing the window is triggering a redraw, the draw method is trying to access a deallocated object, which is causing the crash.


If your intention is to keep "BackGround" around, you need to retain it first. I would recommend reading up on Cocoa memory management.

Nick Zitzmann
<http://www.chronosnet.com/>




_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Crashing View (From: Tom Marchand <email@hidden>)

  • Prev by Date: Crashing View
  • Next by Date: Re: Crashing View
  • Previous by thread: Crashing View
  • Next by thread: Re: Crashing View
  • Index(es):
    • Date
    • Thread