NSWindow alloc/dealloc problems
NSWindow alloc/dealloc problems
- Subject: NSWindow alloc/dealloc problems
- From: Alex Reynolds <email@hidden>
- Date: Mon, 29 Nov 2004 04:07:03 -0500
I have a button that captures and releases a display.
I have a NSWindow ("targetWindow") that contains a NSView
("targetDisplayCino").
When I press the button, my code alloc's the NSWindow object and
populates it with my NSView:
windowLevel = CGShieldingWindowLevel();
cinoScreenRect = [[[NSScreen screens] objectAtIndex:[cinoState
getTargetDisplaySelectedIndex]] frame];
targetWindow = [[NSWindow alloc] initWithContentRect:cinoScreenRect
styleMask:NSBorderlessWindowMask backing:NSBackingStoreRetained
defer:YES];
[targetWindow setLevel:windowLevel];
[targetWindow setBackgroundColor:[NSColor blackColor]];
[targetDisplayCino setFrame:cinoScreenRect display:YES];
[targetWindow setContentView:[targetDisplayCino contentView]];
[targetWindow makeKeyAndOrderFront:nil];
When I press the button again, I have a boolean that executes a
different fork of code. My code needs to destroy the NSWindow object so
that when I release control over the display, the NSWindow will no
longer be visible.
I have tried the following:
[targetWindow close];
and
[targetWindow dealloc];
The close method does not seem to destroy the targetWindow object. If I
run:
NSLog([targetWindow description]);
before and after [targetWindow close], there is a memory address listed
for the object in both NSLog statements.
The second time that I press my Capture button, the application runs
the code in the first part above once again, and crashes with a signal
11 error.
This seems to be a problem where my object is not destroying properly.
The code crashes at the line where targetWindow is being alloc'ed again
(but it is already alloc'ed).
How do I destroy a NSWindow object properly?
Thanks,
Alex
_______________________________________________
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