Make gtk_tree_model_foreach robust

Make gtk_tree_model_foreach safe for callbacks that modify
the model, even if the model does not have persistent iters.

https://bugzilla.gnome.org/show_bug.cgi?id=722781
This commit is contained in:
Matthias Clasen 2014-12-09 00:41:11 -05:00
parent 54e3711c39
commit 1ed5bd07bb

View File

@ -1969,6 +1969,10 @@ gtk_tree_model_foreach_helper (GtkTreeModel *model,
GtkTreeModelForeachFunc func,
gpointer user_data)
{
gboolean iters_persist;
iters_persist = gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_ITERS_PERSIST;
do
{
GtkTreeIter child;
@ -1976,6 +1980,12 @@ gtk_tree_model_foreach_helper (GtkTreeModel *model,
if ((* func) (model, path, iter, user_data))
return TRUE;
if (!iters_persist)
{
if (!gtk_tree_model_get_iter (model, iter, path))
return TRUE;
}
if (gtk_tree_model_iter_children (model, &child, iter))
{
gtk_tree_path_down (path);