[gtk+] Decrease code duplication in _remove_elt_from_level take two
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Decrease code duplication in _remove_elt_from_level take two
- Date: Mon, 22 Aug 2011 19:41:03 +0000 (UTC)
commit c8783d3339218cfce57cb14ec8a2d09742350530
Author: Kristian Rietveld <kris gtk org>
Date: Fri May 20 20:43:48 2011 +0200
Decrease code duplication in _remove_elt_from_level take two
gtk/gtktreemodelfilter.c | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
---
diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c
index c01191d..7771dc9 100644
--- a/gtk/gtktreemodelfilter.c
+++ b/gtk/gtktreemodelfilter.c
@@ -1084,6 +1084,7 @@ gtk_tree_model_filter_remove_elt_from_level (GtkTreeModelFilter *filter,
FilterLevel *parent_level;
gint i, length, parent_elt_index;
GtkTreeIter iter;
+ GtkTreePath *path = NULL;
gboolean emit_child_toggled = FALSE;
@@ -1091,6 +1092,8 @@ gtk_tree_model_filter_remove_elt_from_level (GtkTreeModelFilter *filter,
iter.user_data = level;
iter.user_data2 = elt;
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (filter), &iter);
+
parent_elt_index = level->parent_elt_index;
if (parent_elt_index >= 0)
parent = FILTER_LEVEL_PARENT_ELT (level);
@@ -1122,7 +1125,6 @@ gtk_tree_model_filter_remove_elt_from_level (GtkTreeModelFilter *filter,
if (length > 1)
{
- GtkTreePath *path;
FilterElt *tmp;
/* We emit row-deleted, and remove the node from the cache.
@@ -1132,11 +1134,9 @@ gtk_tree_model_filter_remove_elt_from_level (GtkTreeModelFilter *filter,
if (elt->children)
gtk_tree_model_filter_free_level (filter, elt->children, TRUE);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (filter), &iter);
gtk_tree_model_filter_increment_stamp (filter);
iter.stamp = filter->priv->stamp;
gtk_tree_model_row_deleted (GTK_TREE_MODEL (filter), path);
- gtk_tree_path_free (path);
while (elt->ref_count > 1)
gtk_tree_model_filter_real_unref_node (GTK_TREE_MODEL (filter),
@@ -1170,8 +1170,6 @@ gtk_tree_model_filter_remove_elt_from_level (GtkTreeModelFilter *filter,
else if ((length == 1 && parent && parent->ref_count > 1)
|| (length == 1 && level == filter->priv->root))
{
- GtkTreePath *path;
-
/* We emit row-deleted, but keep the node in the cache and
* referenced. Its children will be removed.
*/
@@ -1182,22 +1180,16 @@ gtk_tree_model_filter_remove_elt_from_level (GtkTreeModelFilter *filter,
elt->children = NULL;
}
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (filter), &iter);
gtk_tree_model_filter_increment_stamp (filter);
gtk_tree_model_row_deleted (GTK_TREE_MODEL (filter), path);
- gtk_tree_path_free (path);
}
else
{
- GtkTreePath *path;
-
/* Blow level away, including any child levels */
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (filter), &iter);
gtk_tree_model_filter_increment_stamp (filter);
iter.stamp = filter->priv->stamp;
gtk_tree_model_row_deleted (GTK_TREE_MODEL (filter), path);
- gtk_tree_path_free (path);
while (elt->ref_count > 1)
gtk_tree_model_filter_real_unref_node (GTK_TREE_MODEL (filter),
@@ -1206,6 +1198,8 @@ gtk_tree_model_filter_remove_elt_from_level (GtkTreeModelFilter *filter,
gtk_tree_model_filter_free_level (filter, level, TRUE);
}
+ gtk_tree_path_free (path);
+
if (emit_child_toggled)
{
GtkTreeIter piter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]