Arcane re-entrant problem with init
Arcane re-entrant problem with init
- Subject: Arcane re-entrant problem with init
- From: Tom Gray <email@hidden>
- Date: Fri, 24 Jan 2003 12:23:20 -0500
Hi Guys,
To everyone, thanks for all the help. Please excuse me if I haven't
responded personally with my thanks.
I am having a strange problem. I have an NSWindowController subclass
that I just converted to a sharedInstance. When I did that I lost the
ability to retain the window frame from launch to launch. My
investigation seems to indicate that I am stuck in a creation loop of
some kind. Odd as it seems the method setFrameAutosaveName is somehow
involved (or more probably it cause the bug to surface).
In my sharedInstance method
+ (CDTerminalController *)sharedInstance
{
static CDTerminalController *sharedInstance = nil;
static int count;
if (!sharedInstance)
{
NSLog(@"sharedInstance == nil count = %i", count++);
sharedInstance = [[CDTerminalController alloc] init];
}
return sharedInstance;
}
I call my NSWindowController init method. I have the method
setFrameAutosaveName in the init method (which I am not sure is correct
since it references a window that has not yet been loaded from the nib)
however, there is really nothing in the init that should cause it to be
re-entrant.
Now, I do have a windowDidLoad method which creates a new object which
itself makes use of my NSWindowControlle subclass to get a pointer to
the sharedInstance. I think that this is where I am looping. I suspect
that my windowDidLoad method creates the other object which in turn
calls the sharedInstance before the object has finished initializing.
The only way for this to happen is if the windowDidLoad method to be
called before the init method is completely run.
Note the init method starts with initWithWindowNibName.
- (CDTerminalController *)init
{
NSLog(@"Beginning Terminal init");
if (self = [super initWithWindowNibName:@"CDTerminal"])
{
So, my question is, does initWithWindowNibName result in windowDidLoad
being called before my init has finished? It seems to. And, what in the
heck dose setFrameAutosaveName have to do with all of this?
What fun, ehh?
Tom Gray
-------------
email@hidden
or
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.