gnustep-dev
[Top][All Lists]
Advanced

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

Re: sending notifications in -dealloc


From: Helge Hess
Subject: Re: sending notifications in -dealloc
Date: Fri, 31 May 2002 16:16:35 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc3) Gecko/20020523

Helge Hess wrote:
This doesn't work on gstep-base, because the NSNotification created retains and afterwards releases the "object:self". This somehow results in a duplicate call to -dealloc (because the RC apparently reaches "0" twice).

Is anyone aware of differences with regards to RC in -dealloc or has any other ideas ?

some more info, NSObject -release looks like this in libFoundation:
---snip---
    if (NSExtraRefCount(self) == 1)
        [self dealloc];
    else
        NSDecrementExtraRefCountWasZero(self);
---snap---

and like that in gstep-base:
---snip---
  if (NSDecrementExtraRefCountWasZero(self))
    {
          [self dealloc];
    }
---snap---

(some code removed).

Actually I think that libFoundation is correct (and apparently it's implemented in the same way in MacOSX Foundation, I'll check that in the evening at home).

Gstep-base is implemented like it's written down in the documentation "If anObject didn't have an extra reference count, it returns YES, indicating that the object should be deallocated (with dealloc)". But this breaks if the count isn't checked (resulting unnecessarily in multiple -deallocs).

Opinions ?

Greetings
  Helge




reply via email to

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