Proposal: gtk_object to emmit reference changed signals
- From: "Sam O'Connor" <oconnor eiffel com>
- To: gtk-devel-list redhat com
- Subject: Proposal: gtk_object to emmit reference changed signals
- Date: Tue, 09 Nov 1999 18:34:52 -0800
I would like some kind of hook to do stuff
when an object's reference count changes.
I guess a signal for ref and one for unref.
I need to be able to do stuff when the count
goes from 1 to 2 and when it goes from 2 to 1.
I am currently working on a problem that
involves getting the GTK+ reference counting
system to cooperate nicely with a mark & sweep
GC in an Eiffel system.
I would like to add these signals and would like
to know if they have any chance of being included
in some future release.
<At this point if you can say "Absolutely no way in
hell" then don't bother reading the gumph below.>
I have Eiffel objects that act as proxies for
the GTK objects. They create a gtk object, ref it
and sink it, thus taking control of its lifetime.
When I tell an eiffel box to add an eiffel button,
gtk_container_add (box, button) is done, I have no
need to hold a reference to my eiffel button in my
eiffel box. Later if I ask for the box's child the
GtkButton is extracted and I can look up the eiffel
object in a global C pointer -> eiffel object map.
This saves me from mirroring knowledge of the box
contents in eiffel, I let GTK be the master and
query it's state when I am interested.
I want my mark & sweep GC in eiffel to clean up
eiffel objects that have GTK objects that have
ref counts of 1.
(ie only the E object refs the GTK one)
But if the GTK object has 2 refs the second one
may end up being used to get to the eiffel object
so I want to keep the eiffel object.
I can have the GTK object hold a reference to
the eiffel object (One that causes the GC not to
kill it (this is done through some magic involving
talking to the Eiffel GC from C)),
so what I want is to detect when the ref count in GTK
drops to 1 and remove the eiffel reference. And also
detect when it goes to 2 and attach the eiffel reference.
(Basically a toggle between a weak/strong ref in eiffel)
This way stuff that the GC doesn't reach in it's marking
phase and that doesn't have a ref from GTK gets killed.
(This eventually leads to little substructures that can
not be reached from the root object being killed as well.)
Basically I want to have a reference to a gtk object
count as a reference to the corresponding eiffel object
as far as the GC is concerned.
(Ignoring the ref the eiffel object itself holds on the GTK object)
As I said above, I'm happy to implement the new signals
but I'd like to get a feel for weather this sounds
outlandish to those of you who know better before
I start.
Thanks
Sam O'Connor
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]