Re: Document-WindowController release misorder
Re: Document-WindowController release misorder
- Subject: Re: Document-WindowController release misorder
- From: Edwin Vane <email@hidden>
- Date: Thu, 18 Aug 2005 09:17:05 -0400
- Mail-followup-to: Cocoa-Dev <email@hidden>
So after doing some investigation with ObjectAlloc (and not using
bindings through the window controller), I discovered that
the window controller was being autoreleased before the doc but both the
release and free events for the window controller were happening after
the documents'.
As I mentioned below, without using a subclassed window controller the
views get deallocated before the doc. This is important since one of my
view components has added itself as observer for each object in an array
it is bound to (to watch for property changes just like in mmalc's
Graphics Bindings example). And just like in that example, it doesn't
remove itself as observer until it is deallocated.
Now, if the view is deallacoted after the doc, of course I get warnings
since the objects that were being watched have now been disappeared.
So my questions are these:
1) Is this release behaviour expected for documents and subclassed
window controllers (not using bindings here)?
2) When I turn the bindings back on, should I be using a better method
for removing 'self' as an observer (ie, not putting it in a dealloc and
expecting the view to be deallocated after the model)?
3) I'm guessing the hack of having the window controller retain the
document until the window controller is deallocated is not a good
idea...
I'm hoping somebody with more Cocoa experience than myself will have an
idea of what is going on here.
On Wed, Aug 17, 2005 at 11:35:27PM -0400, Edwin Vane wrote:
> Hi,
>
> I have an application where my document has a single window and so I use
> windowNibName to provide the name of the nib and Cocoa does the rest
> internally.
>
> In preperation for moving to multiple views, I subclassed the window
> controller to control the main window. I also overrode
> makeWindowControllers like the following:
>
> TimeLineWC *timeLineWC = [[TimeLineWC alloc] init];
> [self addWindowController: timeLineWC];
> [timeLineWC setShouldCloseDocument:YES];
> [timeLineWC release];
>
> There also used to be bindings from an array controller in the nib to
> the old file's owner (the document). I've changed this now to go through
> the document property of the new file's owner (the custom window
> controller).
>
> So with only these basic changes, I'm finding that when the window
> closes now, the document gets deallocated before the views do (which
> produces warnings about deallocating objects while they're being
> observed). Even worse, the views don't appear to be deallocated. When I
> adjust the nib to turn off the binding through the file owner, the
> document still gets released first but at least the views are being
> released now. I'm aware of the problems of binding through the file's
> owner but as far as I know, this only causes leaks, not premature
> deallocations.
>
> As far as I know I was following all the directions/examples but clearly
> I've missed some important detail somewhere. My guess is the window
> controller is being retained by something somewhere. Any ideas what
> might be causing the problem?
>
> --
>
> Edwin Vane
> MMath Candidate
> Computer Graphics Lab
> School of Computer Science
> University of Waterloo
>
> _______________________________________________
> 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
>
--
Edwin Vane
MMath Candidate
Computer Graphics Lab
School of Computer Science
University of Waterloo
_______________________________________________
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