Re: [gtk-list] uref'ing or destroying




On Fri, 20 Aug 1999, Per Erik Stendahl wrote:
> 
> What is the correct thing to do when you want to destroy an object?
> gtk_object_destroy() seems to be the advertised method, but that
> doesn't respect the reference count of the object (at least not
> in 1.2.2 as far as I can see). Looking at gtk_object_unref() I
> see that it will call gtk_object_destroy() when the reference
> count hits zero. Is gtk_object_unref() a Better Way then?
> 

You might want to look at my sample chapters at
http://pobox.com/~hp/gnome-app-devel.html; they discuss this in some
detail. Look for the "object finalization" section.

Notably, _destroy() doesn't _finalize() an object until the refcount hits
zero, so holding a refcount does ensure the object will be "valid" (still 
safe to access) although destroyed-but-not-yet-finalized objects are
"useless."

If an object is shared and has no real "owner," then you might use
_unref() only and never destroy. 

Havoc




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