summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-08-11 14:22:17 -0400
committerPietro Gagliardi <[email protected]>2014-08-11 14:22:17 -0400
commit7d578d261775f5b034eafe522000d23fa96cc563 (patch)
tree0505bd0d8a5bcc9469e362c16864d0157e6109b3
parentb1a2ed827b39e1161eb0bbfdc72cd3fe06e2dacd (diff)
Resolved failure conditions in the GTK+ Table GtkTreeModel implementation.
-rw-r--r--redo/table_unix.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/redo/table_unix.c b/redo/table_unix.c
index 21dc38b..d77a16e 100644
--- a/redo/table_unix.c
+++ b/redo/table_unix.c
@@ -85,7 +85,7 @@ bad:
static GtkTreePath *goTableModel_get_path(GtkTreeModel *model, GtkTreeIter *iter)
{
if (iter->stamp != GOOD_STAMP)
- return NULL; /* TODO is this right? */
+ return NULL; /* this is what both GtkListStore and GtkTreeStore do */
return gtk_tree_path_new_from_indices((gint) iter->user_data, -1);
}
@@ -94,7 +94,8 @@ static void goTableModel_get_value(GtkTreeModel *model, GtkTreeIter *iter, gint
goTableModel *t = (goTableModel *) model;
gchar *str;
- /* TODO what if iter is invalid? */
+ if (iter->stamp != GOOD_STAMP)
+ return; /* this is what both GtkListStore and GtkTreeStore do */
/* we (actually cgo) allocated str with malloc(), not g_malloc(), so let's free it explicitly and give the GValue a copy to be safe */
str = goTableModel_do_get_value(t->gotable, (gint) iter->user_data, column);
/* value is uninitialized */
@@ -109,7 +110,7 @@ static gboolean goTableModel_iter_next(GtkTreeModel *model, GtkTreeIter *iter)
gint index;
if (iter->stamp != GOOD_STAMP)
- return FALSE; /* TODO correct? */
+ return FALSE; /* this is what both GtkListStore and GtkTreeStore do */
index = (gint) iter->user_data;
index++;
iter->user_data = (gpointer) index;
@@ -126,7 +127,7 @@ static gboolean goTableModel_iter_previous(GtkTreeModel *model, GtkTreeIter *ite
gint index;
if (iter->stamp != GOOD_STAMP)
- return FALSE; /* TODO correct? */
+ return FALSE; /* this is what both GtkListStore and GtkTreeStore do */
index = (gint) iter->user_data;
index--;
iter->user_data = (gpointer) index;