Re: GObject and Gtk+ Finalization

On Mon, Sep 25, 2000 at 09:04:21AM -0400, Havoc Pennington wrote:
> You just removed the count owned by pass_object_to_owner(). The
> floating count remains, but can be removed at any time.

Yes, with an unref

> > In both cases, after this we end up with a refcount of 1, which is
> > held by the pass_object_to_owner thing.  If you just ignore the
> > floating flag, things should just work.
> George, you are on crack. ;-) Yes this "works." No it does not really


> work. You can't go removing other people's counts, and claim it's
> remotely a good idea because it happens to work out.

Anyway, I think we are talking on different levels.  You are saying do a
ref/sink in init to make sure that simple refcounting only is used.  Thus
anything that uses sink on it will be wrong and buggy.

I say, screw that, I just use simple refcounting and ignore the floating

Either way, code that uses sink is buggy and won't work right (either leak or
unref one too many times).

But regardless, the argument is moot since both ways work.  The reason for my
argument was not saying that doing a ref/sink in init is bad, but that it's
not neccessary functinally, and I thought you said that it is.  Wheather it's
cleaner or less prone to user code bugs is a different story.

> Yes, you are missing that using this interface has rules of sanity,
> and that if you have some GtkObject with different refcount rules than
> some other GtkObject you are smoking a lot of crack because GtkObject
> is where the refcount interface lives. Changing refcount rules at
> random is a good way to create memory leaks/corruption.

Well, the refcount rules I see are the code.  And that's what it says.
Actually from what I can see, just about 90% of all non-widget GtkObjects in
different GNOME things are NEVER sunk, yet their refcounting is still ok.


George <jirka 5z com>
   The ability to quote is a serviceable substitute for wit.
                       -- W. Somerset Maugham

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