diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2012-07-15 21:14:33 -0400 |
---|---|---|
committer | Jasper St. Pierre <jstpierre@mecheye.net> | 2012-12-05 13:43:19 -0500 |
commit | 7ee5e7af702a6b2794ee6529a617e8dd7af1944a (patch) | |
tree | 52ac13974db7ec0f165b3a3613596d03907b0cf1 | |
parent | a61b3594987d7cf91bcff071f3b8181c4a3a27de (diff) | |
download | gtk+-7ee5e7af702a6b2794ee6529a617e8dd7af1944a.tar.gz |
treemodelfilter: Make the constructor binding friendly
This means reffing the root in the set property implementation,
rather than in the constructor. We don't need to unref the root
on set, as it's a CONSTRUCT_ONLY property.
https://bugzilla.gnome.org/show_bug.cgi?id=680065
-rw-r--r-- | gtk/gtktreemodelfilter.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c index a8ef24b826..45281c298a 100644 --- a/gtk/gtktreemodelfilter.c +++ b/gtk/gtktreemodelfilter.c @@ -3758,10 +3758,14 @@ gtk_tree_model_filter_set_root (GtkTreeModelFilter *filter, { g_return_if_fail (GTK_IS_TREE_MODEL_FILTER (filter)); - if (!root) - filter->priv->virtual_root = NULL; + if (root) + { + filter->priv->virtual_root = gtk_tree_path_copy (root); + gtk_tree_model_filter_ref_path (filter, filter->priv->virtual_root); + filter->priv->virtual_root_deleted = FALSE; + } else - filter->priv->virtual_root = gtk_tree_path_copy (root); + filter->priv->virtual_root = NULL; } /* public API */ @@ -3782,24 +3786,12 @@ GtkTreeModel * gtk_tree_model_filter_new (GtkTreeModel *child_model, GtkTreePath *root) { - GtkTreeModel *retval; - GtkTreeModelFilter *filter; - g_return_val_if_fail (GTK_IS_TREE_MODEL (child_model), NULL); - retval = g_object_new (GTK_TYPE_TREE_MODEL_FILTER, - "child-model", child_model, - "virtual-root", root, - NULL); - - filter = GTK_TREE_MODEL_FILTER (retval); - if (filter->priv->virtual_root) - { - gtk_tree_model_filter_ref_path (filter, filter->priv->virtual_root); - filter->priv->virtual_root_deleted = FALSE; - } - - return retval; + return g_object_new (GTK_TYPE_TREE_MODEL_FILTER, + "child-model", child_model, + "virtual-root", root, + NULL); } /** |