Hi List,

I'm having some problems with memory management of a window controller in a standard NSDocument based application. The problem is that my window controller gets released through an autorelease pool after the document has been deallocated (and released it in the process).

I've overwritten release and retain on the this window controller be able to examine the retain/release cycle. Unfortunately overwriting - autorelease does not work (contrary to -retain and -release) so I can't break when it's being put into the autorelease pool (why I don't know).

My document is creating the window controller in

- (void)makeWindowControllers
{
controller = [[RubiWindowController alloc] initWithWindowNibName:@"RubiDocument"];
    [controller setShouldCloseDocument:YES];
    [self addWindowController:controller];

}

and releases it in -dealloc:

- (void)dealloc
{
    [controller release];
    [super dealloc];
}

Until here everything is balanced. The release here causes the controller's -dealloc: being executed.

However after this, an autorelease pool releases it again, which causes a EXC_BAD_ACCESS crash:

#0      0x949e36e8 in objc_msgSend
#1      0x94078cb6 in CFArrayApplyFunction
#2      0x9574d305 in -[NSView _recursiveBreakKeyViewLoop]
#3      0x94078cb6 in CFArrayApplyFunction
#4      0x9574d305 in -[NSView _recursiveBreakKeyViewLoop]
#5      0x94078cb6 in CFArrayApplyFunction
#6      0x9574d305 in -[NSView _recursiveBreakKeyViewLoop]
#7      0x9574bbe9 in -[NSWindow dealloc]
#8      0x9539e57f in NSPopAutoreleasePool
#9      0x956e2e54 in -[NSApplication run]
#10     0x956b0030 in NSApplicationMain
#11     0x00003946 in main at main.m:13

I've tried both settings of "Releases when closed" in IB, but it crashes regardless of this setting.

Am I not supposed to release the window controller in the document even though I create it?

Thanks for any pointers!

Regards
Markus
--
__________________________________________
Markus Spoettl

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to