summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid King <amigadave@amigadave.com>2012-11-22 17:38:41 +0000
committerDavid King <amigadave@amigadave.com>2012-11-22 21:34:58 +0000
commit1bad36ae1db1006b4f2f06f3fb3828efc0130a45 (patch)
treeb7a3b027d1e5f6e83baeffee67604870f01cfe09
parent92f536b907c25fabec79181e2f617c27ca0b4ff9 (diff)
downloadgtk+-1bad36ae1db1006b4f2f06f3fb3828efc0130a45.tar.gz
docs: Improve GtkTreeModel iteration pattern
Iterating over the model in this way means that use of continue is less error-prone, as the increment is part of the loop construct. https://bugzilla.gnome.org/show_bug.cgi?id=548793
-rw-r--r--gtk/gtktreemodel.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/gtk/gtktreemodel.c b/gtk/gtktreemodel.c
index a2abeaddcc..31d8843509 100644
--- a/gtk/gtktreemodel.c
+++ b/gtk/gtktreemodel.c
@@ -168,12 +168,12 @@
* /&ast; Fill the list store with data &ast;/
* populate_model (list_store);
*
- * /&ast; Get the first iter in the list &ast;/
- * valid = gtk_tree_model_get_iter_first (list_store, &amp;iter);
- *
- * while (valid)
+ * /&ast; Get the first iter in the list, check it is valid and walk
+ * &ast; through the list, reading each row. &ast;/
+ * for (valid = gtk_tree_model_get_iter_first (list_store, &amp;iter);
+ * valid;
+ * valid = gtk_tree_model_iter_next (list_store, &amp;iter))
* {
- * /&ast; Walk through the list, reading each row &ast;/
* gchar *str_data;
* gint int_data;
*
@@ -190,7 +190,6 @@
* g_free (str_data);
*
* row_count++;
- * valid = gtk_tree_model_iter_next (list_store, &amp;iter);
* }
* </programlisting>
* </example>