[gtkada] Storage leak when changing button graphics

christoph.grein at eurocopter.com christoph.grein at eurocopter.com
Fri Jul 4 07:47:49 CEST 2003


I'm still using the old 1.x version :-(

In my application, I need to change the graphic on a button. I do this with the 
following code:

    Gtk.Button.Remove (Button, Graphic);

    Gdk.Pixmap.Create_From_XPM_D (Pixmap, Get_Window (Button), Mask,
                                  Transparent => Gdk.Color.Null_Color,
                                  Data        => XPM);
    Gtk.Pixmap.Gtk_New (Graphic, Pixmap, Mask);
    Gtk.Button.Add (Button, Graphic);

Now I performed a robustness test and changed the graphic very often. The result 
is that after some time, the program runs short of memory and the button is 
displayed blank (no graphic), a while later the program crashes, so the above 
code leaks.

What is the correct way to change graphics on buttons?



More information about the gtkada mailing list