[Gtk-sharp-list] Re: Gtk# hacking
20 Sep 2001 20:57:40 -0500
On Thu, 2001-09-20 at 17:30, Bob Smith wrote:
> The proposed solution is to make a static delegate type for each type of
> signal callback, keep a perminantly pinned instance of it laying around,
> and have it registered when needed. So, assuming both "clicked" and
> "destroyed" in the previous example are the same function type, the total
> number of delegates is reduced to 1. You can have 50 buttons each with a
> clicked method, and only one delegate gets pinned. This is MUCH easier on
> the garbage collector and memory in general. All other delegates remain
> managed, so nothing else needs pining.
How does the static callback know whether it is being called for a
clicked event or a destroyed event if it's being shared in this manner?
Are we going to have to connect to the raw signal with data indicating
the fully qualified event name and put another hashtable in to map that
to the real event emitter?
> As to how the delegate gets access to what wrapper object it needs, there
> is a static Object function that gets the associated wrapper of a GObject.
> The wrapper is stored in a static hash table, the hash key is an int
> converted to an IntPtr and stored as data in the GObject. The delegate
> uses this function to get the wrapper, then calls the appropriate event on
> the wrapper.
I meant to comment on this earlier. Why do we need to store this in the
raw object? Can't we just use the raw object IntPtr directly as a key
to the hash? That would save some PInvoke roundtrips.
> I have all this already coded over here, and I can dump it into cvs if
> you'd like. It may require a few min to make sure everything compiles, but
> it should be pritty close.
It sounds like a good improvement. If you already have the problem of
mapping back to the signal specific callback solved, go ahead and commit
this and I'll see if I can work out any kinks when I get back on Sunday.