Problems with Styles (was Re: [gtkada] Tasking with GtkAda for newbies)

Emmanuel Briot briot at gnat.com
Fri Feb 9 17:30:42 CET 2001


 > OK thanks, I tried:
 > 
 >    Style := Get_Style (Notify_Dialog.Base_Ebox);
 >    Set_Rgb (Cyan_Col,  23_810, 45_755, 47_000);
 >    Set_Background (Style, State_Normal, Cyan_Col);
 >    Set_Style (Notify_Dialog.Base_Ebox, Style);
 >    Unref (Style);

 > I guess the Unref should be moved to where the dialog is Destroyed? But
 > then I need to figure out how to change the Callback function first.


As I was explaining, when you do Get_Style, this just copies the value of a
pointer. You are then freeing the pointed structure, so when
Notify_Dialog.Base_Ebox tries to access it,... You can imagine the rest.

If you don't do Gtk_New or Copy, there is no need to Unref the style. gtk+
takes care of that when the widget is destroyed (this is what reference
counting is all about). The problem appears when you allocate some memory that
isn't referenced anywhere else. There is no garbage collecting, so that memory
wouldn't be freed.

Emmanuel




More information about the gtkada mailing list