Fix crash when iterating through the tree model

Don't use indices to move through iterators, don't skip the first
section, and verify that we got a new iterator before using it
(bug #591392).
This commit is contained in:
Jens Granseuer 2009-08-11 18:01:55 +02:00
parent 1dee15363d
commit 5998aa90c0

View file

@ -522,25 +522,20 @@ find_section (GtkTreeModel *model,
GtkTreeIter *iter, GtkTreeIter *iter,
const char *title) const char *title)
{ {
gint i, j; gboolean success, found;
gboolean found;
i = gtk_tree_model_iter_n_children (model, NULL);
found = FALSE; found = FALSE;
gtk_tree_model_get_iter_first (model, iter); success = gtk_tree_model_get_iter_first (model, iter);
for (j = 0; j < i; j++) while (success && !found)
{ {
char *description = NULL; char *description = NULL;
gtk_tree_model_iter_next (model, iter);
gtk_tree_model_get (model, iter, gtk_tree_model_get (model, iter,
DESCRIPTION_COLUMN, &description, DESCRIPTION_COLUMN, &description,
-1); -1);
if (g_strcmp0 (description, title) == 0)
{ found = (g_strcmp0 (description, title) == 0);
found = TRUE; success = gtk_tree_model_iter_next (model, iter);
break;
}
} }
if (!found) if (!found)
{ {