On Tue, Jul 14, 2009 at 2:42 PM, Adam Fedor <[email protected]> wrote:

> There must be something wrong somewhere else.  If dealloc is being called
> more than once, then somewhere there are two many 'releases' for the number
> of 'retains' you have.
>
> In fact, if the NSSound is stored in nameDict, then dealloc should have
> never been called in the first place, as nameDict implicitly retains the
> NSSound (if that is the only place that the NSSound is removed from
> nameDict). So that means you have at least two too many releases somewhere
> else.
>

OK, I understand this now... it would seen that I have a problem than.

According to the apple docs whenever a sound is created using
-iniWithContentsOfFile:byReference: or a name is set using -setName: I must
be able to later find it using the +soundNamed: method, at least that's how
I understand it.  Because the NSSound object is retained when added to the
nameDict dictionary I will have 1 extra retain that what I would want and
the sound will never get deallocated.  The problem I'm having a hard time
solving here is: I must keep the NSSound object in nameDict in order to be
able to return it whenever +soundNamed: is called, but doing so will
increase my ref count +1 and I do not want that.

The reason I was able to get -dealloc called was because I called DESTROY()
instead of RELEASE().  The current NSSound code calls TEST_RELEASE() instead
of RELEASE(), so it gets away with calling -dealloc twice.

Did I explain that clearly?  Let me know if I need clarify anything.  Does
anyone have any suggestions?

Thanks
Stefan
_______________________________________________
Gnustep-dev mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/gnustep-dev

Reply via email to