Recent

Author Topic: Working with GList  (Read 3622 times)

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1248
Working with GList
« on: August 06, 2011, 12:21:31 am »
G'day,

I've noticed a few places in gtk2wscustomlistview.inc where we're getting a GList from the underlying GTK IconView, but we're not then free'ing this GList.  This is inconsistent throughout the unit - sometimes it's free'd simply using g_list_free(), othertimes it's not free'd at all.

Checking the GTK documentation http://developer.gnome.org/gtk/2.24/GtkIconView.html#gtk-icon-view-get-selected-items, looks like we should be calling both g_list_free, and g_list_foreach each and every time.

So, my first question is - does anyone know if we *need* to call free, or if there's some garbage collection mechanism in GTK going on?

If we do need to free the GList's after ourselves, does anyone know how to call g_list_foreach?  I've tried g_list_foreach(List, gtk_tree_path_free, nil) and g_list_foreach(List, @gtk_tree_path_free, nil) - neither compile...

My final question is the one I'm going through now...  How do I check to see if there any GTK objects leaked? 

And apologies if this is the wrong forum to post this to - not sure what the relationship between GTK and glib is, and this is really a glib question...
« Last Edit: August 06, 2011, 12:33:41 am by Mike.Cornflake »
Lazarus Trunk/FPC Trunk on Windows [7, 10]
  Have you tried searching this forum or the wiki?:   http://wiki.lazarus.freepascal.org/Alternative_Main_Page
  BOOKS! (Free and otherwise): http://wiki.lazarus.freepascal.org/Pascal_and_Lazarus_Books_and_Magazines