summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorKristian Rietveld <kris@gtk.org>2006-06-12 14:48:43 +0000
committerKristian Rietveld <kristian@src.gnome.org>2006-06-12 14:48:43 +0000
commit563f28a88d44dd188e951e09adb7814ea18bcc4f (patch)
tree231badadc056a42c119f35dc42d29d3fdc53027f /gtk
parent6bc87f5d3be68b8ce0bc3751eea21a08eb5c1ede (diff)
downloadgtk+-563f28a88d44dd188e951e09adb7814ea18bcc4f.tar.gz
report status in return value instead of spewing assertions. (#335729,
2006-06-12 Kristian Rietveld <kris@gtk.org> * gtk/gtktreemodelfilter.[ch] (gtk_tree_model_filter_convert_child_iter_to_iter), (gtk_tree_model_filter_convert_child_path_to_path): report status in return value instead of spewing assertions. (#335729, Yevgen Muntyan).
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtktreemodelfilter.c33
-rw-r--r--gtk/gtktreemodelfilter.h2
2 files changed, 24 insertions, 11 deletions
diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c
index 7d16935aed..4349004c50 100644
--- a/gtk/gtktreemodelfilter.c
+++ b/gtk/gtktreemodelfilter.c
@@ -2987,34 +2987,43 @@ gtk_tree_model_filter_set_visible_column (GtkTreeModelFilter *filter,
* @child_iter: A valid #GtkTreeIter pointing to a row on the child model.
*
* Sets @filter_iter to point to the row in @filter that corresponds to the
- * row pointed at by @child_iter.
+ * row pointed at by @child_iter. If @filter_iter was not set, %FALSE is
+ * returned.
+ *
+ * Return value: %TRUE, if @filter_iter was set, i.e. if @child_iter is a
+ * valid iterator pointing to a visible row in child model.
*
* Since: 2.4
*/
-void
+gboolean
gtk_tree_model_filter_convert_child_iter_to_iter (GtkTreeModelFilter *filter,
GtkTreeIter *filter_iter,
GtkTreeIter *child_iter)
{
+ gboolean ret;
GtkTreePath *child_path, *path;
- g_return_if_fail (GTK_IS_TREE_MODEL_FILTER (filter));
- g_return_if_fail (filter->priv->child_model != NULL);
- g_return_if_fail (filter_iter != NULL);
- g_return_if_fail (child_iter != NULL);
+ g_return_val_if_fail (GTK_IS_TREE_MODEL_FILTER (filter), FALSE);
+ g_return_val_if_fail (filter->priv->child_model != NULL, FALSE);
+ g_return_val_if_fail (filter_iter != NULL, FALSE);
+ g_return_val_if_fail (child_iter != NULL, FALSE);
filter_iter->stamp = 0;
child_path = gtk_tree_model_get_path (filter->priv->child_model, child_iter);
- g_return_if_fail (child_path != NULL);
+ g_return_val_if_fail (child_path != NULL, FALSE);
path = gtk_tree_model_filter_convert_child_path_to_path (filter,
child_path);
gtk_tree_path_free (child_path);
- g_return_if_fail (path != NULL);
- gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), filter_iter, path);
+ if (!path)
+ return FALSE;
+
+ ret = gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), filter_iter, path);
gtk_tree_path_free (path);
+
+ return ret;
}
/**
@@ -3152,7 +3161,8 @@ gtk_real_tree_model_filter_convert_child_path_to_path (GtkTreeModelFilter *filte
* Converts @child_path to a path relative to @filter. That is, @child_path
* points to a path in the child model. The rerturned path will point to the
* same row in the filtered model. If @child_path isn't a valid path on the
- * child model, then %NULL is returned.
+ * child model or points to a row which is not visible in @filter, then %NULL
+ * is returned.
*
* Return value: A newly allocated #GtkTreePath, or %NULL.
*
@@ -3171,6 +3181,9 @@ gtk_tree_model_filter_convert_child_path_to_path (GtkTreeModelFilter *filter,
TRUE,
TRUE);
+ if (!path)
+ return NULL;
+
/* get a new path which only takes visible nodes into account.
* -- if this gives any performance issues, we can write a special
* version of convert_child_path_to_path immediately returning
diff --git a/gtk/gtktreemodelfilter.h b/gtk/gtktreemodelfilter.h
index df13cf8c47..e9ab5829b2 100644
--- a/gtk/gtktreemodelfilter.h
+++ b/gtk/gtktreemodelfilter.h
@@ -84,7 +84,7 @@ void gtk_tree_model_filter_set_visible_column (GtkTreeModelFilt
GtkTreeModel *gtk_tree_model_filter_get_model (GtkTreeModelFilter *filter);
/* conversion */
-void gtk_tree_model_filter_convert_child_iter_to_iter (GtkTreeModelFilter *filter,
+gboolean gtk_tree_model_filter_convert_child_iter_to_iter (GtkTreeModelFilter *filter,
GtkTreeIter *filter_iter,
GtkTreeIter *child_iter);
void gtk_tree_model_filter_convert_iter_to_child_iter (GtkTreeModelFilter *filter,