re: gtk_signal_connect_interp()



Marc Ewing wrote:
> 
> Owen Taylor <owt1@cornell.edu> writes:
> > > if I need to have the
> > > data portion of a signal handler freed or taken care of in some
> > > way when the handler is removed, I need to do something like:
> > >
> > >  gtk_signal_connect_interp(GTK_OBJECT(item), "expand",
> > >                            expand_tree, s, g_free, FALSE);
> > >
> > > (where the data, s, is the result of a g_strdup()).  Is this
> > > correct?  Does gtk_signal_connect_interp() do more than that?
> > > Is there some other way to accomplish what I need?
> >
> > Hmmm. Right now, this won't work, because gtk_signal_connect_interp
> > expects the function to be a special marshall function instead of an
> > everyday garden-variety signal handler.  I discussed solutions to this
> > problem with Marius a few months ago, but nothing came of it.
> >
> > For now, the right thing to do is to free your data in the "destroy"
> > callback (and if you gtk_signal_disconnect anywhere explicitly, also
> > free it there).
> 
> Is there a "legal" way to obtain the data pointer for a signal
> handler during the destroy so I don't have to keep a table of
> those data pointers around anywhere?
>

[snip]

Umm, what about:

..
gtk_object_set_data(GTK_OBJECT(item),"gtk_sig_data/expand",(gpointer)s);
..
s=(ghcar *)gtk_object_get_data(GTK_OBJECT(item),"gtk_sig_data/expand");
free(s);
..

(substitute "gtk_sig_data/expand" with whatever unique)

Perhaps not very elegant, but..

Tom

--

tomb@gimp.org



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