Skip navigation.
 
mlRe: NSWindow alloc/dealloc problems
FROM : j o a r
DATE : Mon Nov 29 19:01:34 2004

On 2004-11-29, at 18.47, Alex Reynolds wrote:

> Close does trigger a release (because I told it to in
> setReleasedWhenClosed) which in turn should dealloc the NSWindow
> instance.


Agreed - IFF no one else is retaining the window.

>> I'm not quite sure that I understand why you assign the content view
>> to the window like that.

> How else do I assign a content view to a window? I'm only reading
> Apple's documentation, now.


Perhaps I'm just not understanding you (when you create a new window it
comes with a content view already in place). One valid reason for doing
what you're doing is of course if the NSPanel instance that you're
creating has some special content view that you want to use instead of
the content view that's already in your "targetWindow"?

> If I change the target display (in a multiple monitor setup) or change
> the target display mode (resolution of a selected monitor), the
> content view doesn't change (and shouldn't need releasing) but the
> NSWindow object instance does need to be remade, depending on the
> state of the application when the capture button is pressed.


Is it not enough to simply resize and / or reposition it (-[NSWindow
setFrame:display:])?

But never mind that - To get somewhere with your crashes I suggest that
you create an instance variable to your content view and retain it:

   targetDisplayCino = [[NSPanel alloc] init];
   targetDisplayCinoContentView = [[targetDisplayCino contentView]
retain];

And later in dealloc:

   [targetDisplayCinoContentView release];

That should prevent it from being deallocated when you swap it between
windows.

j o a r

Related mailsAuthorDate
mlNSWindow alloc/dealloc problems Alex Reynolds Nov 29, 10:07
mlRe: NSWindow alloc/dealloc problems j o a r Nov 29, 10:24
mlRe: NSWindow alloc/dealloc problems Alex Reynolds Nov 29, 10:32
mlRe: NSWindow alloc/dealloc problems j o a r Nov 29, 10:42
mlRe: NSWindow alloc/dealloc problems Lorenzo Nov 29, 12:06
mlRe: NSWindow alloc/dealloc problems Alex Reynolds Nov 29, 18:02
mlRe: NSWindow alloc/dealloc problems j o a r Nov 29, 18:19
mlRe: NSWindow alloc/dealloc problems Alex Reynolds Nov 29, 18:47
mlRe: NSWindow alloc/dealloc problems j o a r Nov 29, 19:01
mlRe: NSWindow alloc/dealloc problems Alex Reynolds Nov 29, 19:53
mlRe: NSWindow alloc/dealloc problems j o a r Nov 29, 20:23
mlRe: NSWindow alloc/dealloc problems Alex Reynolds Nov 29, 20:26
mlRe: NSWindow alloc/dealloc problems j o a r Nov 29, 20:35
mlRe: NSWindow alloc/dealloc problems M. Uli Kusterer Nov 29, 20:42