For a plain GObject:
$pixbuf = Gtk2::Gdk::Pixbuf->new (...);
- C function returns object with one reference.
- wrapper adds one reference.
- binding knows that this function is a constructor, so it removes
one reference to ensure that the wrapper is the sole owner.
and
$pixbuf = $pixbuf_loader->get_pixbuf; # you don't own the return yet!
- C function returns object with n refs.
- wrapper adds one reference.
Contrast this with a GtkObject:
$button = Gtk2::Button->new ("hi");
breaks down into
- C function returns object with one floating ref
- wrapper refs and sinks, becoming sole owner.
Whereas:
$child = $widget->get_child;
breaks down into
- C function returns sunken object with n refs.
- wrapper refs and sinks. was already sunk, so sink does nothing, and
C object gets another ref owned by the wrapper.