[gtkada] learning GtkAda

Dmitry A. Kazakov mailbox at dmitry-kazakov.de
Fri Oct 26 13:50:36 CEST 2012


On Fri, 26 Oct 2012 12:36:27 +0200, you wrote:

>> As for memory management, you are fully exposed to the GTK/glib
>> reference counting model with all its pitfalls (e.g. floating vs. not
>> objects). GTK memory management is among the first things you should
>> learn and understand.
> 
> Hmm...a bit confused here...
> 
> Looking at: http://docs.adacore.com/gtkada-docs/gtkada_ug/_build/html/memory.html
> 
> page, it says: "GtkAda takes care of almost all the memory management
> for you...Thus, every time a C object is destroyed, the equivalent Ada
> structure is also destroyed (see Gtk.Free_User_Data)...So the
> deallocation of a widget hierarchy is also performed automatically."
> 
> What does it mean then?

It means that you need not to care about any Ada objects created to
interface C objects of GTK. There is no additional troubles with that, not
"almost" as it says, but none whatsoever, I would say.

But the GTK memory management issues are still yours. You need to unref and
not to unref objects when necessary. You must take into account how the
closures work when you pass objects with. For example when one widget is
passed as a parameter to the handler of signals of another widget when
neither widget holds a reference count of another, when some does etc.

There are some GtkAda means to ease that too, but still you have to keep in
mind that the stuff is low-level and dangerous.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


More information about the gtkada mailing list