• 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
Custom Field Editor Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom Field Editor Problem


  • Subject: Custom Field Editor Problem
  • From: John Nairn <email@hidden>
  • Date: Tue, 2 Feb 2010 11:02:55 -0800

I copied code from Cocoa documentation to create a custom field editor. It gets created OK and seems to work, but always crashes when the the window closes with the message

Program received signal:  “EXC_BAD_ACCESS”.
sharedlibrary apply-load-rules all

I created the custom editor in the window controller using code from Apple:

- (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id) anObject
{
if([anObject isKindOfClass:[NSTextField class]])
{ if(!customEditor)
{ customEditor=[[BrowserFieldEditor alloc] init];
[customEditor setFieldEditor:YES];
}
return customEditor;
}
return nil;
}


When the window controller is deallocated, it calls

[customEditor dealloc];

Finally, the entire custom editor, which is NSTextView subclass, is

@implementation BrowserFieldEditor

- (id)init
{   if(self=[super init])
    {   NSLog(@"init field editor");
    }
    return self;
}

- (void)dealloc
{    NSLog(@"dealloc field editor");
    [super dealloc];
}

@end

The "init field editor" message appears when created and the "dealloc field editor" appears just before the crash. If I change the window controller to not release the custom editor, the crash stops, but the "dealloc field editor" message never appears (i.e., a memory leak). Also the Apple documentation explicitly says:

The custom field editor should be released in an appropriate place, such as the dealloc method of the window delegate object (if the field editor was never instantiated, therelease message has no effect and is harmless).

------------
John Nairn
http://www.geditcom.com
Genealogy Software for the Mac

_______________________________________________

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


  • Follow-Ups:
    • Re: Custom Field Editor Problem
      • From: Corbin Dunn <email@hidden>
    • Re: Custom Field Editor Problem
      • From: Ross Carter <email@hidden>
  • Prev by Date: Re: Arbitrary Attributes affect text layout
  • Next by Date: Re: NSTableView questions (take 2)
  • Previous by thread: Re: HELP! My app crashes on startup, with a very weird stack trace.
  • Next by thread: Re: Custom Field Editor Problem
  • Index(es):
    • Date
    • Thread