Re: GWeakNotify fired earlier than expected



Hi,

On Mon, Mar 16, 2009 at 12:45 PM, IdaRub <idarub gmail com> wrote:
> After reading the gobject code a bit more, it seems that weak
> references are fired on dispose, not finalize:
>

Right, that's correct.

> All of the documentation I could find states that it happens during
> finalization, but it seems it should all say that it happens during
> dispose.

Probably true. dispose is typically done during finalize, but can
happen sooner also. dispose can happen multiple times.

> In my example this detail is actually very important.
> Doesn't look like there is a way to catch dispose without shimming the
> instance handler.  Any ideas?

You mean there's no way to catch finalize?

Finalize deliberately can't be intercepted, because it raises a lot of
thorny issues about reentrancy; what if the object is used or its
refcount increased during finalization?

So things are split into two phases, dispose() which you can get
notifications about (and which can happen multiple times); and
finalize which actually frees the object.

Havoc


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