diff options
-rw-r--r-- | widgets/table/e-table-subset.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/widgets/table/e-table-subset.c b/widgets/table/e-table-subset.c index d4a2415f13..a237ba2d94 100644 --- a/widgets/table/e-table-subset.c +++ b/widgets/table/e-table-subset.c @@ -41,6 +41,9 @@ static ETableModelClass *etss_parent_class; #define ETSS_CLASS(object) (E_TABLE_SUBSET_GET_CLASS(object)) +#define VALID_ROW(etss, row) (row >= -1 && row < etss->n_map) +#define MAP_ROW(etss, row) (row == -1 ? -1 : etss->map_table[row]) + static gint etss_get_view_row (ETableSubset *etss, int row) { @@ -144,9 +147,11 @@ etss_value_at (ETableModel *etm, int col, int row) { ETableSubset *etss = (ETableSubset *)etm; + g_return_val_if_fail (VALID_ROW (etss, row), NULL); + etss->last_access = row; d(g_print("g) Setting last_access to %d\n", row)); - return e_table_model_value_at (etss->source, col, etss->map_table [row]); + return e_table_model_value_at (etss->source, col, MAP_ROW(etss, row)); } static void @@ -154,9 +159,11 @@ etss_set_value_at (ETableModel *etm, int col, int row, const void *val) { ETableSubset *etss = (ETableSubset *)etm; + g_return_if_fail (VALID_ROW (etss, row)); + etss->last_access = row; d(g_print("h) Setting last_access to %d\n", row)); - e_table_model_set_value_at (etss->source, col, etss->map_table [row], val); + e_table_model_set_value_at (etss->source, col, MAP_ROW(etss, row), val); } static gboolean @@ -164,7 +171,9 @@ etss_is_cell_editable (ETableModel *etm, int col, int row) { ETableSubset *etss = (ETableSubset *)etm; - return e_table_model_is_cell_editable (etss->source, col, etss->map_table [row]); + g_return_val_if_fail (VALID_ROW (etss, row), FALSE); + + return e_table_model_is_cell_editable (etss->source, col, MAP_ROW(etss, row)); } static gboolean @@ -178,10 +187,12 @@ etss_get_save_id (ETableModel *etm, int row) { ETableSubset *etss = (ETableSubset *)etm; + g_return_val_if_fail (VALID_ROW (etss, row), NULL); + if (e_table_model_has_save_id (etss->source)) - return e_table_model_get_save_id (etss->source, etss->map_table [row]); + return e_table_model_get_save_id (etss->source, MAP_ROW(etss, row)); else - return g_strdup_printf ("%d", etss->map_table[row]); + return g_strdup_printf ("%d", MAP_ROW(etss, row)); } static void |