mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-14 12:41:07 +00:00
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:
parent
54e3711c39
commit
1ed5bd07bb
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user