discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSViewController; loading views from nibs


From: Ivan Vučica
Subject: Re: NSViewController; loading views from nibs
Date: Fri, 15 Apr 2011 22:05:51 +0200

On Mon, Jan 24, 2011 at 12:44, Fred Kiefer <fredkiefer@gmx.de> wrote:
>
> I read a bit of Apple docs and figured out how loading from nibs is done. I
> added support in Zcode, and  prepared a patch for GNUstep GUI. It's clumsy
> but works for my needs.

I submitted a patch similar to yours. This class will still need some
work to be truly useful.


Hi Fred,

It seems to me that your implementation of NSViewController's -loadView (which I tested only now) has a bug with retaincount. I never took a deep look at what NSNib is doing, but it seems to me that nib being released at the end of loadView pulls all other objects with it. That's just my guess.

This bug is manifesting in Zcode. I have NSViewController subclasses for the editor, which are unloaded upon file switch and replaced with a different NSViewController. All of them are defined in nibs.

Program crashes when I release the old subclass of NSViewController. The crash occurs in NSViewController's release, when _topObjects is released.

This problem did not occur with my original submitted patch, which has used the same method that is used in NSWindowController's -loadWindow. Zcode used this method for a while, and it seems ok to me. Zcode also runs under Cocoa, so I guess I am Doing Things Right(tm). 

Here is a patch that uses the same method that I used in Zcode. It fixes the crash and exposes -loadView publicly (which I think is ok, since people who subclass NSViewController should know that -loadView exists).

Please tell me if I introduced a memory leak; I don't know exactly what I'm doing and basically I'm learning from NSWindowController's source code.

--
Ivan Vučica
ivan@vucica.net
Coming soon for iPhone, Zombie Ball - http://j.mp/zbivmail


Attachment: nsviewcontroller.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]