[gtkada] Deallocating memory shared as user data

Emmanuel Briot briot at ACT-Europe.FR
Mon Feb 18 10:14:35 CET 2002


William C Brennan <brennan at netaxs.com> writes:

> I've created and displayed a window widget.  I also allocated from the heap a
> record which contains references to some of the widgets in the window.  A
> pointer to this record is passed to several widget callback routines, as user
> data, so when one widgets can share information with one another.  To me, this
> seems like a typical way in which widgets and the user-data parameter in their
> callback routines are designed to interact.


One way I think you could proceed is to indeed connect to the "destroy" event,
but not destroy the widgets themselves in the callback. (Just free your record
with Unchecked_Deallocation, and let gtk+ take care of its widgets).
gtk+ and GtkAda will automatically reclaim the memory allocated for the
widgets, so all you should really care about is your record and possibly the
Ada data types associated with it.

regards,
Emmanuel




More information about the gtkada mailing list