[gtk+] Make _get_iter invalidate iterators when FALSE is returned



commit 2f5fbcd10a4856d99d4e8a9a333a816e3035f625
Author: Kristian Rietveld <kris gtk org>
Date:   Mon May 9 09:51:50 2011 +0200

    Make _get_iter invalidate iterators when FALSE is returned

 gtk/gtkliststore.c       |    5 ++++-
 gtk/gtktreemodel.c       |    3 ++-
 gtk/gtktreemodelfilter.c |    2 ++
 gtk/gtktreemodelsort.c   |   10 ++++++++--
 gtk/gtktreestore.c       |   10 ++++++++--
 5 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkliststore.c b/gtk/gtkliststore.c
index b6533e4..5ed838f 100644
--- a/gtk/gtkliststore.c
+++ b/gtk/gtkliststore.c
@@ -647,7 +647,10 @@ gtk_list_store_get_iter (GtkTreeModel *tree_model,
   i = gtk_tree_path_get_indices (path)[0];
 
   if (i >= g_sequence_get_length (seq))
-    return FALSE;
+    {
+      iter->stamp = 0;
+      return FALSE;
+    }
 
   iter->stamp = priv->stamp;
   iter->user_data = g_sequence_get_iter_at_pos (seq, i);
diff --git a/gtk/gtktreemodel.c b/gtk/gtktreemodel.c
index f004300..26f6d73 100644
--- a/gtk/gtktreemodel.c
+++ b/gtk/gtktreemodel.c
@@ -1186,7 +1186,8 @@ gtk_tree_model_get_column_type (GtkTreeModel *tree_model,
  * @iter: (out): the uninitialized #GtkTreeIter
  * @path: the #GtkTreePath
  *
- * Sets @iter to a valid iterator pointing to @path.
+ * Sets @iter to a valid iterator pointing to @path.  If @path does
+ * not exist, * @iter is set to an invalid iterator and %FALSE is returned.
  *
  * Return value: %TRUE, if @iter was set
  */
diff --git a/gtk/gtktreemodelfilter.c b/gtk/gtktreemodelfilter.c
index c76514e..3f5e21f 100644
--- a/gtk/gtktreemodelfilter.c
+++ b/gtk/gtktreemodelfilter.c
@@ -2318,6 +2318,7 @@ gtk_tree_model_filter_get_iter_full (GtkTreeModel *model,
     {
       if (!level || indices[i] >= level->array->len)
         {
+          iter->stamp = 0;
           return FALSE;
         }
 
@@ -2375,6 +2376,7 @@ gtk_tree_model_filter_get_iter (GtkTreeModel *model,
     {
       if (!level || indices[i] >= level->visible_nodes)
         {
+          iter->stamp = 0;
           return FALSE;
         }
 
diff --git a/gtk/gtktreemodelsort.c b/gtk/gtktreemodelsort.c
index 9daa32f..c518612 100644
--- a/gtk/gtktreemodelsort.c
+++ b/gtk/gtktreemodelsort.c
@@ -1092,13 +1092,19 @@ gtk_tree_model_sort_get_iter (GtkTreeModel *tree_model,
 
   depth = gtk_tree_path_get_depth (path);
   if (depth == 0)
-    return FALSE;
+    {
+      iter->stamp = 0;
+      return FALSE;
+    }
 
   for (i = 0; i < depth - 1; i++)
     {
       if ((level == NULL) ||
 	  (indices[i] >= level->array->len))
-	return FALSE;
+        {
+          iter->stamp = 0;
+          return FALSE;
+        }
 
       if (g_array_index (level->array, SortElt, indices[i]).children == NULL)
 	gtk_tree_model_sort_build_level (tree_model_sort, level, indices[i]);
diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c
index e2e969e..e0d40dd 100644
--- a/gtk/gtktreestore.c
+++ b/gtk/gtktreestore.c
@@ -560,13 +560,19 @@ gtk_tree_store_get_iter (GtkTreeModel *tree_model,
   parent.user_data = priv->root;
 
   if (!gtk_tree_store_iter_nth_child (tree_model, iter, &parent, indices[0]))
-    return FALSE;
+    {
+      iter->stamp = 0;
+      return FALSE;
+    }
 
   for (i = 1; i < depth; i++)
     {
       parent = *iter;
       if (!gtk_tree_store_iter_nth_child (tree_model, iter, &parent, indices[i]))
-	return FALSE;
+        {
+          iter->stamp = 0;
+          return FALSE;
+        }
     }
 
   return TRUE;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]