Re: Fwd: Re: Fwd: Re: GTK_FLOATING broken in 2.9?



On Thu, 15 Dec 2005, ANDREW PAPROCKI, BLOOMBERG/ 731 LEXIN wrote:

Yevgen Muntyan wrote:

New code:

object = fancy_not_gtk_object_new();
g_object_ref_sink(object); /* because I don't know what will container do */
fancy_container_add(container, object);
g_object_unref(object);

What I want the container code to do is assert if an object is not floating, and
ref_sink internally. So the user's code will look like:

object = fancy_not_gtk_object_new();
fancy_container_add(container, object);

asserting floating state is usually a bad idea, because the floating
reference count is a one-shot indicator for unknown object ownership.
once the ownership is clear, the object shouldn't become less usable
(certainly bad for the "owner" ;)

that'd disallow scenarios like:

  object = fancy_not_gtk_object_new();
  do_stuff (object);
  fancy_container_add(container, object);

where do_stuff() could be adding + removing to/from another container.
or it could be:
  do_stuff (object) { this->list += g_object_ref_sink (object); }
  // destructor cleans up this->list

or it could be setting up a python/perl/etc. proxy for object.
or maybe you have:
  object = from_perl_code_create ("SomeObject");
or:
  object = UIFactory::create_object ("XmlFileObject");
which return already sunken objects.

Andrew Paprocki
Bloomberg LP


---
ciaoTJ



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