• 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: drawing NSTextFieldCell nested inside NSTextFieldCell subclass causes crash
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawing NSTextFieldCell nested inside NSTextFieldCell subclass causes crash


  • Subject: Re: drawing NSTextFieldCell nested inside NSTextFieldCell subclass causes crash
  • From: Dan Donaldson <email@hidden>
  • Date: Fri, 20 Oct 2006 13:03:34 -0400

This is the implementation I used:

- copyWithZone:(NSZone *)zone {
DDDoubleTextFieldCell * cell = (DDDoubleTextFieldCell *)[super copyWithZone:zone];
cell->cellTitle = [cellTitle retain];
cell->titleField = [titleField retain];
return cell;
}



however, the line cell->titleField = [titleField retain]; causes a crash for reasons not clear to me.





Dan Donaldson 416 604 3398 email@hidden



On 20-Oct-06, at 6:44 AM, Mike Abdullah wrote:

Have you properly implemented your new cell's copyWithZone: method? NSCells get copied a lot when being drawn. If you don't implement this, the table view will copy your cell incorrectly and screw up your memory management.

Mike.

On 19 Oct 2006, at 21:13, Dan Donaldson wrote:

I have an NSTextField subclass. Its function is to provide a cell with two vertically stacked text areas in one cell.

Things are generally working ok, its being instantiated, put into a column in an NSOutlineView. I've shifted the default text area down 18.0 pixels, to leave space for the upper textfield. This is an NSTextFieldCell, stored in an instance variable called titleField in the cell. This is being created on init of the cell, and that's confirmed using NSLog.

When I try to draw the extra cell, I use this:

// -----------------------------
- (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *) controlView {
NSSize titleSize;
NSRect titleFrame;

titleSize.width = 300.0;
titleSize.height = 18.0;

NSDivideRect (cellFrame,&titleFrame,&cellFrame,titleSize.height,NSMinYEdge);

NSLog(@"frames: \rcell x: %f y: %f w:%f h:%f \r\r title: x: %f y: %f w:%f h:%f",
cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, cellFrame.size.height,
titleFrame.origin.x, titleFrame.origin.y, titleFrame.size.width, titleFrame.size.height);
if ( titleField != nil) {
[titleField drawWithFrame:titleFrame inView:controlView];
}
[super drawWithFrame:cellFrame inView:controlView];
}


and the application crashes. I'm not very experienced with Cocoa, but this seems reasonable. The frames are both there, but it isn't working...nothing has been done with titleFrame except alloc/init/ autorelease. cellSize is being used to manipulate the row height correctly.

Help (please)...

Dan Donaldson
416 604 3398
email@hidden



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >drawing NSTextFieldCell nested inside NSTextFieldCell subclass causes crash (From: Dan Donaldson <email@hidden>)
 >Re: drawing NSTextFieldCell nested inside NSTextFieldCell subclass causes crash (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Is it possible to handle a mouse click in an NSTextView without subclassing it?
  • Next by Date: Binding table view custom cell background colour
  • Previous by thread: Re: drawing NSTextFieldCell nested inside NSTextFieldCell subclass causes crash
  • Next by thread: Re: NSToolbar with NSSearchField crash (caused by menu?)
  • Index(es):
    • Date
    • Thread