diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-12-09 00:41:11 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-12-11 09:22:32 -0500 |
commit | ff669c6b12a9e95cbfb6f1e2804e6fda0188ed98 (patch) | |
tree | f5dbcdeb1ac74dfdfe4932d6f5db0bac4fb169e2 | |
parent | 866c9a498d23961875117fadeef14c1dfbbe6dad (diff) | |
download | gtk+-ff669c6b12a9e95cbfb6f1e2804e6fda0188ed98.tar.gz |
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
-rw-r--r-- | gtk/gtktreemodel.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gtk/gtktreemodel.c b/gtk/gtktreemodel.c index 39065621f7..8bbf55d025 100644 --- a/gtk/gtktreemodel.c +++ b/gtk/gtktreemodel.c @@ -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); |