Re: Leaking despite gtk_list_store_clear()
- From: Andrew Smith <asmith15 learn senecac on ca>
- To: gtk-app-devel-list gnome org
- Subject: Re: Leaking despite gtk_list_store_clear()
- Date: Sun, 01 Jul 2007 00:20:47 -0400
Andrew Smith a écrit :
Hi
I am using a GtkTreeView to display the contents of the filesystem in my
application. It always worked (I mostly followed
http://scentric.net/tutorial/) but I just found that it leaks memory.
My understanding of the tree view model is somewhat limited so I won't
try to speculate about what's causing the leak - all I know is it
happens even though I call gtk_list_store_clear() on my GtkListStore*.
Would someone please take a look? It's relatively simple code, the leak
happens in changeFsDirectory(): http://littlesvr.ca/misc/fsbrowser.c
(it's part of ISO Master).
If you don't have the time to look at it, would you at least suggest
common reasons why repopulating a GtkListStore* would cause a memory leak?
Thanks in advance,
Andrew
Hello again
I found the problem. It wasn't in the file I referenced, it was in the
sort function which did a gtk_tree_model_get(string) without freeing the
string. Sorry for bothering you, but I hope this message gets archived
and helps out someone who's got the same problem and is searching for a
solution.
By the way, I also fixed a huge performance problem with the same code.
It turns out most of the time it took me to change the directory was
spent in the function that compared the rows. It also turns out there is
no way to disable sorting temporarily (while the list is repopulated).
What I've done is to make a sort function that simply always returns 0;
and set that sort function on all the columns while the list was
repopulated. I would humbly suggest this should go in the GTK
documentation, since it's a problem that anyone with long lists needs to
deal with.
Of course it would be even better if a
gtk_tree_sortable_enable_sort(gboolean) were added in the next minor GTK
version :)
Should I post this suggestion to gtk-devel-list, or do they read this
list as well?
Cheers,
Andrew
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]