[gtkada] Storage leak when changing button graphics

christoph.grein at eurocopter.com christoph.grein at eurocopter.com
Mon Jul 7 06:33:31 CEST 2003


Manuel Op de Coul schrieb:

> Try calling Unref(Pixmap) after adding it to the button.

Manuel, thanx for this hint, but it does not change the behaviour. This is the 
relevant code excerpt:

  procedure Set_Button_Pixmap (Button : in  Gtk.Button.Gtk_Button;
                               XPM    : in  GtkAda.Types.Chars_Ptr_Array;
                               Graphic: out Gtk.Pixmap.Gtk_Pixmap) is
    Pixmap: Gdk.Pixmap.Gdk_Pixmap;
    Mask  : Gdk.Bitmap.Gdk_Bitmap;
  begin
    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);
    Add (Button, Graphic);
    Gdk.Pixmap.Unref (Pixmap);
  end Set_Button_Pixmap;

  Graphic_Undo  : Gtk.Pixmap.Gtk_Pixmap;
  Undo_Available: Boolean;

  procedure On_Clicked (Object: access Gtk_Button_Record'Class) is

    function Undo_XPM return GtkAda.Types.Chars_Ptr_Array is
    begin
      if Undo_Available then
        return XPMs.Undo;
      else
        return XPMs.Undo_Inactive;
      end if;
    end Undo_XPM;

  begin

    Remove            (Window.Undo, Graphic_Undo);
    Set_Button_Pixmap (Window.Undo, Undo_XPM, Graphic_Undo);
    Show_All          (Window.Undo);
    Undo_Available := not Undo_Available;

  end On_Clicked;

When I run it (on Win98, GtkAda 1.x), after about 1100 calls, the program begins 
to behave strangely. So it seems that it still leaks.

I can send the complete program if necessary.

Any hint is appreciated.

                                 o     _      _          _
 --------- __o       __o      /\_    _ \\o   (_)\__/o   (_)
 ------- _`\<,_    _`\<,_    _>(_)  (_)/<_     \_| \    _|/' \/
 ------ (_)/ (_)  (_)/ (_)  (_)         (_)    (_)     (_)'  _\o_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mein Radunfall
My bike accident


Christoph Grein
Mitglied von Ada-Deutschland, Ada-Europe
Member of Ada Germany, Ada Europe
http:/www.ada-deutschland.de
http:/www.ada-europe.org

http://home.T-Online.de/home/Christ-Usch.Grein
eMail: Christ-Usch.Grein at T-Online.de



More information about the gtkada mailing list