Re: Leopard Crashing in Open and Save Panels (not solved?)
Re: Leopard Crashing in Open and Save Panels (not solved?)
- Subject: Re: Leopard Crashing in Open and Save Panels (not solved?)
- From: John Stiles <email@hidden>
- Date: Tue, 04 Dec 2007 16:17:06 -0800
This looks like an issue with zombie objects (you're releasing
/some/thing before its time, and this leads to random crashes later).
Try turning on NSZombieEnabled and see what you get.
John Nairn wrote:
The app is crashing again even with retains of the save panel. It is
also crashing on a menu command linked to saveDocument:. It gets from
menu command to Cocoa NSDocument and crashes before I can select a
document. I was hoping others had seen something similar and can tell
me what I must be doing wrong. But I am at a loss because it is not
crashing in my code or (sometimes) not even a method called from my code.
After adding a category to NSSavePanel, a crash from the method listed
below occurred again. My category indicated my "retain" of the
NSSavePanel and also showed there was no "release" before the crash.
Thus the crash can not be retain-release issue (unless garbage
collection disposes it without ever calling release?). I found the
following in the debugger window regarding what happened after leaving
my method
#0 0x965126e8 in objc_msgSend
#1 0x918aad1e in -[NSConcreteNotification recycle]
#2 0x918b4108 in -[NSNotificationCenter postNotificationName:object:]
#3 0x91b8215f in -[NSWindow _setWindowNumber:]
#4 0x91b81a90 in -[NSWindow _commonInitFrame:styleMask:backing:defer:]
#5 0x91b811ee in -[NSWindow
_initContent:styleMask:backing:defer:contentView:]
#6 0x91c1ddf0 in -[NSPanel
_initContent:styleMask:backing:defer:contentView:]
#7 0x91b80baa in -[NSWindow
initWithContentRect:styleMask:backing:defer:]
#8 0x91c1dd8a in -[NSPanel
initWithContentRect:styleMask:backing:defer:]
#9 0x91dc0bd5 in -[NSSavePanel
initWithContentRect:styleMask:backing:defer:]
#10 0x91dc0a43 in +[NSSavePanel _crunchyRawUnbonedPanel]
#11 0x0000af58 in -[TextController exportXMLCommands:] at
TextController.m:369
Maybe a notification problem?
On Dec 4, 2007, at 2:00 PM, John Stiles wrote:
Actually, hmm, I don't know if my idea will work because you're not
allocating a save panel, you're getting it from -savePanel.
Maybe you could put a category on NSSavePanel and add your -release
and -autorelease in there? (This assumes that NSSavePanel doesn't
already override -release and -autorelease, but I think that's an OK
assumption for debugging purposes—just don't ship code that way.)
John Stiles wrote:
I'd think that we'd have seen it occur in many other apps already if
there wasn't something else going on here.
Have you tried making a subclass of NSSavePanel, overriding -release
and -autorelease and then putting breakpoints in it? (And call
[super release] or [super autorelease] to actually get it to
release.) That can tell you who is doing the extra release.
John Nairn wrote:
The following method would crash frequently in Leopard although it
never crashed in past 5 years before Leopard.
// save copy to results file
- (IBAction)exportXMLCommands:(id)sender
{
NSSavePanel *pan = [NSSavePanel savePanel];
[pan beginSheetForDirectory:nil file:nil
modalForWindow:[self window] modalDelegate:self
didEndSelector:@selector(exportXMLPanelDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
// if OK, sav text in new file
- (void)exportXMLPanelDidEnd:(NSSavePanel *)sheet
returnCode:(int)returnCode
contextInfo:(void *)contextInfo
{
}
It would crash in the NSSavePanel method soon after the sheet
opened and before returning to my code.
The crashes have stopped by retaining the panel in the first method
NSSavePanel *pan = [[NSSavePanel savePanel] retain];
and releasing when the sheet is finished.
[sheet release];
I am wondering if the new garbage collection in Leopard has caused
this problem? My project is set to "unsupported" for garbage
collect, but does that stop Cocoa objects themselves from using it?
Furthermore, I have seen crashes in the open panel which is handled
entirely by the NSDocument class. Since there is no panel for me to
retain, what would be a good solution for those crashes?
---------------
John Nairn (1-541-737-4265, FAX:1-541-737-3385)
Professor and Richardson Chair
Web Page: http://woodscience.oregonstate.edu/faculty/Nairn
FEA/MPM Web Page: http://oregonstate.edu/~nairnj
_______________________________________________
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
---------------
John Nairn (1-541-737-4265, FAX:1-541-737-3385)
Professor and Richardson Chair
Web Page: http://woodscience.oregonstate.edu/faculty/Nairn
FEA/MPM Web Page: http://oregonstate.edu/~nairnj
_______________________________________________
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