Glib::Refptr and circular references



Hi all,

The occasion of using a Glib::Refptr from gtkmm's API recently reminds
me about an old question. I've been wondering for some time now how
the GObject-using world deals with the problem of circular references.
The classic example would be a node of a (circular) linked list which
is also pointed to by application code. Once the app drops its ref to
the node, at least one more reference (the internal back-edge from the
linked list) still exists.

Now, I know that Glib has a special-built linked list data structure
to prevent this elementary example, but it's fairly easy to imagine
scenarios where this happens unintentionally. Is this simply a known
limitation, accompanied by the stern warning to be careful in one's
design not to introduce circular references?

Apologies if there's already a manifesto about this somewhere in the
Glib tutorial, but I didn't find it.

--Matt



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