diff --git a/lib/egg/eggtreemodelfilter.c b/lib/egg/eggtreemodelfilter.c index d4136121e2..fbe6403b11 100644 --- a/lib/egg/eggtreemodelfilter.c +++ b/lib/egg/eggtreemodelfilter.c @@ -21,6 +21,8 @@ #include "eggtreemodelfilter.h" #include #include + +/* FIXME: remove this when we move it to GTK+ */ #include "eggintl.h" /* ITER FORMAT: @@ -979,14 +981,10 @@ egg_tree_model_filter_row_changed (GtkTreeModel *c_model, gtk_tree_model_get_iter (c_model, &real_c_iter, c_path); /* is this node above the virtual root? */ - if (filter->virtual_root) - { - if (gtk_tree_path_get_depth (filter->virtual_root) >= - gtk_tree_path_get_depth (c_path)) - { - goto done; - } - } + if (filter->virtual_root + && (gtk_tree_path_get_depth (filter->virtual_root) + >= gtk_tree_path_get_depth (c_path))) + goto done; /* what's the requested state? */ requested_state = egg_tree_model_filter_visible (filter, &real_c_iter); @@ -1102,8 +1100,8 @@ egg_tree_model_filter_row_inserted (GtkTreeModel *c_model, gpointer data) { EggTreeModelFilter *filter = EGG_TREE_MODEL_FILTER (data); - GtkTreePath *path; - GtkTreePath *real_path; + GtkTreePath *path = NULL; + GtkTreePath *real_path = NULL; GtkTreeIter iter; GtkTreeIter real_c_iter; @@ -1282,14 +1280,19 @@ done_and_emit: FALSE, TRUE); if (!path) - return; + goto done; egg_tree_model_filter_increment_stamp (filter); gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path); gtk_tree_model_row_inserted (GTK_TREE_MODEL (data), path, &iter); + gtk_tree_path_free (path); + done: + if (real_path) + gtk_tree_path_free (real_path); + if (free_c_path) gtk_tree_path_free (c_path); } @@ -1393,89 +1396,80 @@ egg_tree_model_filter_row_deleted (GtkTreeModel *c_model, c_path, FALSE, FALSE); + if (!path) { - path = egg_real_tree_model_filter_convert_child_path_to_path (filter, - c_path, - FALSE, - TRUE); - - if (!path) - { - /* fixup the offsets */ - GtkTreePath *real_path; - - if (!filter->root) - return; + /* fixup the offsets */ + GtkTreePath *real_path; - level = FILTER_LEVEL (filter->root); + if (!filter->root) + return; - /* subtract vroot if necessary */ - if (filter->virtual_root) - { - real_path = egg_tree_model_filter_remove_root (c_path, - filter->virtual_root); - /* we don't handle this */ - if (!real_path) - return; - } - else - real_path = gtk_tree_path_copy (c_path); + level = FILTER_LEVEL (filter->root); - i = 0; - if (gtk_tree_path_get_depth (real_path) - 1 >= 1) - { - while (i < gtk_tree_path_get_depth (real_path) - 1) - { - gint j; + /* subtract vroot if necessary */ + if (filter->virtual_root) + { + real_path = egg_tree_model_filter_remove_root (c_path, + filter->virtual_root); + /* we don't handle this */ + if (!real_path) + return; + } + else + real_path = gtk_tree_path_copy (c_path); - if (!level) - { - /* we don't cover this */ - gtk_tree_path_free (real_path); - return; - } + i = 0; + if (gtk_tree_path_get_depth (real_path) - 1 >= 1) + { + while (i < gtk_tree_path_get_depth (real_path) - 1) + { + gint j; - elt = bsearch_elt_with_offset (level->array, - gtk_tree_path_get_indices (real_path)[i], - &j); + if (!level) + { + /* we don't cover this */ + gtk_tree_path_free (real_path); + return; + } + elt = bsearch_elt_with_offset (level->array, + gtk_tree_path_get_indices (real_path)[i], + &j); - if (!elt || !elt->children) - { - /* parent is filtered out, so no level */ - gtk_tree_path_free (real_path); - return; - } - level = elt->children; - i++; - } - } + if (!elt || !elt->children) + { + /* parent is filtered out, so no level */ + gtk_tree_path_free (real_path); + return; + } - offset = gtk_tree_path_get_indices (real_path)[gtk_tree_path_get_depth (real_path) - 1]; - gtk_tree_path_free (real_path); + level = elt->children; + i++; + } + } - if (!level) - return; + offset = gtk_tree_path_get_indices (real_path)[gtk_tree_path_get_depth (real_path) - 1]; + gtk_tree_path_free (real_path); - /* we need: - * - the offset of the removed item - * - the level - */ - for (i = 0; i < level->array->len; i++) - { - elt = &g_array_index (level->array, FilterElt, i); - if (elt->offset > offset) - elt->offset--; - if (elt->children) - elt->children->parent_elt = elt; - } + if (!level) + return; - return; - } + /* we need: + * - the offset of the removed item + * - the level + */ + for (i = 0; i < level->array->len; i++) + { + elt = &g_array_index (level->array, FilterElt, i); + if (elt->offset > offset) + elt->offset--; + if (elt->children) + elt->children->parent_elt = elt; + } - emit_signal = FALSE; + return; } gtk_tree_model_get_iter (GTK_TREE_MODEL (data), &iter, path);