Freeing data connected to a widget via signals...




Let's say I have:

typedef struct{
   char *some_dyn_allocd_mem;
   char *some_more_mem
   struct other_structure *ptr;   /* Contains further nested pointers */
} foobar;

and then I create a dynamically allocated foobar (with some subfields that
are dynamically allocated) - call it "ptr"

then I do:

gtk_signal_connect(GTK_OBJECT(my_button), "clicked",
                   GTK_SIGNAL_FUNC(my_button_callback), ptr);

How do I know if "ptr" will be correctly freed when the widget gets
destroyed?  How do I attach a "rider" onto the destroyed signal so that I
can do a custom free routine on the object data when the widget gets
destroyed?

I tried gtk_signal_connect_after(GTK_OBJECT(my_button), "destroy",
                                 GTK_SIGNAL_FUNC(my_custom_foobar_free)
ptr);

but it never seems to get called.

I can't imagine GTK+ knows how to free the fields in my custom data
structure, yet at the same time, I don't know how to do it myself.

Anybody have an idea how I can do that?

Thanks
David
http://opop.nols.com/ Free Software Development
==========================================================================
Der Horizont vieler Menschen ist ein Kreis mit Radius Null -- und das
nennen sie ihren Standpunkt.
==========================================================================
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'



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