Re: GTK_FLOATING broken in 2.9?



On Tue, 20 Dec 2005, Havoc Pennington wrote:

Hi,

[much theoretical rant that i don't think is worth discussing in detail again]

Full proposal:

- GObject has a floating flag, but it's false by default and
  object creator owns a hard reference
- there's a method float() to set the floating flag to true;
  you must own a reference to call it, and the ref you own
  becomes community property / floating
- GFloatingObject calls float() at construct time to float the
  initial reference; creator of GFloatingObject owns no ref
- GtkObject also calls float() at construct time, but does not
  derive from GFloatingObject, just uses the same facilities
  to implement floating
- it's an error to unref with the floating flag set
  and refcount = 1
- (optionally) in the gtk+ stack, GFloatingObject is never used,
  because it would be too confusing to mix these in with the old
  APIs
- (definitely) something that's a GObject today can't be changed to
  GFloatingObject or to call float(), this is incompatible

that'd mean you have g_floating_object_ref_sink() and gtk_object_sink(),
and you can't use the former on the latter without good reason.

also, why is the floating flag introduced on GObject right away
but can only be used on a GFLoatingObject?

to me it seems like, in your proposal the only reason to have
GFloatingObject at all is to change the floating default upon
creation, so GObject can stay a non-floating object base type
like Dave Benson already suggested here:
  http://mail.gnome.org/archives/gtk-devel-list/2005-December/msg00213.html

picking up this particular idea will actually give us:

GObject:
- created with ref_count=1
- not initially floating

/* check whether a GObject is floating */
gboolean    g_object_is_floating              (gpointer        object);

/* force a GObject to have a floating reference, reserved for
 * object implementors (or eventually language bindings)
 */
void        g_object_force_floating           (GObject        *object);

/* reference an object, remove possible floating reference */
gpointer    g_object_ref_sink                 (gpointer        object);

GFloatingObject, derived from GObject:
- created with ref_count=1
- initial reference is floating

GtkObject, derived from GFloating object:
- created with ref_count=1
- initial reference is floating
- floating flag is implemented as GtkObject.flags&GTK_FLOATING
  via a compat hook, i.e. g_object_ref_sink() will work on this
  and GTK_OBJECT_SET_FLAGS() will as well.


Havoc


---
ciaoTJ



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