diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2000-08-26 17:15:32 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2000-08-26 17:15:32 +0800 |
commit | 20925d94eb5649df410820e67017a299ce5d867d (patch) | |
tree | 34a29bc7dc4aca4cae7fd97e5aa5a97497f4926b /widgets | |
parent | 4c768a32bf0d07dea885d7e23da66762a7d2c82a (diff) | |
download | gsoc2013-evolution-20925d94eb5649df410820e67017a299ce5d867d.tar.gz gsoc2013-evolution-20925d94eb5649df410820e67017a299ce5d867d.tar.zst gsoc2013-evolution-20925d94eb5649df410820e67017a299ce5d867d.zip |
Added some g_return_if_fails and g_return_val_if_fails.
2000-08-25 Christopher James Lahey <clahey@helixcode.com>
* e-table-col.c, e-table-config.c, e-table-header.c,
e-table-text-model.c: Added some g_return_if_fails and
g_return_val_if_fails.
svn path=/trunk/; revision=5056
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/e-table/ChangeLog | 6 | ||||
-rw-r--r-- | widgets/e-table/e-table-col.c | 10 | ||||
-rw-r--r-- | widgets/e-table/e-table-config.c | 21 | ||||
-rw-r--r-- | widgets/e-table/e-table-header.c | 32 | ||||
-rw-r--r-- | widgets/e-table/e-table-text-model.c | 7 | ||||
-rw-r--r-- | widgets/table/e-table-col.c | 10 | ||||
-rw-r--r-- | widgets/table/e-table-config.c | 21 | ||||
-rw-r--r-- | widgets/table/e-table-header.c | 32 | ||||
-rw-r--r-- | widgets/table/e-table-text-model.c | 7 | ||||
-rw-r--r-- | widgets/text/e-table-text-model.c | 7 |
10 files changed, 122 insertions, 31 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog index 9d677393ca..3fba867267 100644 --- a/widgets/e-table/ChangeLog +++ b/widgets/e-table/ChangeLog @@ -1,3 +1,9 @@ +2000-08-25 Christopher James Lahey <clahey@helixcode.com> + + * e-table-col.c, e-table-config.c, e-table-header.c, + e-table-text-model.c: Added some g_return_if_fails and + g_return_val_if_fails. + 2000-08-24 Christopher James Lahey <clahey@helixcode.com> * e-table.c: Fix an off by one error that was causing crashes. diff --git a/widgets/e-table/e-table-col.c b/widgets/e-table/e-table-col.c index 0e7c14f748..c6a734b3ee 100644 --- a/widgets/e-table/e-table-col.c +++ b/widgets/e-table/e-table-col.c @@ -97,7 +97,9 @@ e_table_col_new (int col_idx, const char *text, double expansion, int min_width, g_return_val_if_fail (expansion >= 0, NULL); g_return_val_if_fail (min_width >= 0, NULL); + g_return_val_if_fail (ecell != NULL, NULL); g_return_val_if_fail (compare != NULL, NULL); + g_return_val_if_fail (text != NULL, NULL); etc = gtk_type_new (E_TABLE_COL_TYPE); @@ -129,7 +131,9 @@ e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf, double expansion, i g_return_val_if_fail (expansion >= 0, NULL); g_return_val_if_fail (min_width >= 0, NULL); + g_return_val_if_fail (ecell != NULL, NULL); g_return_val_if_fail (compare != NULL, NULL); + g_return_val_if_fail (pixbuf != NULL, NULL); etc = gtk_type_new (E_TABLE_COL_TYPE); @@ -157,12 +161,18 @@ e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf, double expansion, i void e_table_col_set_arrow (ETableCol *col, ETableColArrow arrow) { + g_return_if_fail (col != NULL); + g_return_if_fail (E_IS_TABLE_COL(col)); + col->arrow = arrow; } ETableColArrow e_table_col_get_arrow (ETableCol *col) { + g_return_val_if_fail (col != NULL, E_TABLE_COL_ARROW_NONE); + g_return_val_if_fail (E_IS_TABLE_COL(col), E_TABLE_COL_ARROW_NONE); + return col->arrow; } diff --git a/widgets/e-table/e-table-config.c b/widgets/e-table/e-table-config.c index 5d078f8f86..d124fe5d2d 100644 --- a/widgets/e-table/e-table-config.c +++ b/widgets/e-table/e-table-config.c @@ -150,7 +150,10 @@ e_table_gui_config (ETable *etable) GladeXML *gui; GnomeDialog *dialog; ConfigData *config_data; - + + g_return_val_if_fail(etable != NULL, NULL); + g_return_val_if_fail(E_IS_TABLE(etable), NULL); + glade_gnome_init (); gui = glade_xml_new (ETABLE_GLADEDIR "/e-table-config.glade", NULL); if (!gui) @@ -193,16 +196,26 @@ e_table_gui_destroy_config_data (GtkWidget *widget) gtk_object_destroy (GTK_OBJECT (cd->gui)); g_free (cd); } - + void e_table_gui_config_accept (GtkWidget *widget, ETable *etable) { + g_return_if_fail(etable != NULL); + g_return_if_fail(E_IS_TABLE(etable)); + g_return_if_fail(widget != NULL); + g_return_if_fail(GTK_IS_WIDGET(widget)); + e_table_gui_destroy_config_data (widget); } void e_table_gui_config_cancel (GtkWidget *widget, ETable *etable) { + g_return_if_fail(etable != NULL); + g_return_if_fail(E_IS_TABLE(etable)); + g_return_if_fail(widget != NULL); + g_return_if_fail(GTK_IS_WIDGET(widget)); + e_table_gui_destroy_config_data (widget); } @@ -212,6 +225,10 @@ e_table_do_gui_config (GtkWidget *parent, ETable *etable) GnomeDialog *dialog; int r; + g_return_if_fail(etable != NULL); + g_return_if_fail(E_IS_TABLE(etable)); + g_return_if_fail(parent == NULL || GTK_IS_WINDOW(parent)); + dialog = GNOME_DIALOG (e_table_gui_config (etable)); if (!dialog) return; diff --git a/widgets/e-table/e-table-header.c b/widgets/e-table/e-table-header.c index fddda13da8..0f8f9ed1e9 100644 --- a/widgets/e-table/e-table-header.c +++ b/widgets/e-table/e-table-header.c @@ -348,7 +348,7 @@ e_table_header_index (ETableHeader *eth, int col) { g_return_val_if_fail (eth != NULL, -1); g_return_val_if_fail (E_IS_TABLE_HEADER (eth), -1); - g_return_val_if_fail (col < eth->col_count, -1); + g_return_val_if_fail (col >= 0 && col < eth->col_count, -1); return eth->columns [col]->col_idx; } @@ -376,6 +376,7 @@ ETableCol ** e_table_header_get_columns (ETableHeader *eth) { ETableCol **ret; + int i; g_return_val_if_fail (eth != NULL, 0); g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); @@ -384,6 +385,10 @@ e_table_header_get_columns (ETableHeader *eth) memcpy (ret, eth->columns, sizeof (ETableCol *) * eth->col_count); ret [eth->col_count] = NULL; + for (i = 0; i < eth->col_count; i++) { + gtk_object_ref(GTK_OBJECT(ret[i])); + } + return ret; } @@ -479,11 +484,16 @@ e_table_header_remove (ETableHeader *eth, int idx) void e_table_header_set_selection (ETableHeader *eth, gboolean allow_selection) { + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); } void e_table_header_set_size(ETableHeader *eth, int idx, int size) { + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); + enqueue(eth, idx, size); } @@ -610,21 +620,19 @@ int e_table_header_col_diff (ETableHeader *eth, int start_col, int end_col) { int total, col; - + g_return_val_if_fail (eth != NULL, 0); g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - { - if (start_col < 0) - start_col = 0; - if (end_col > eth->col_count) - end_col = eth->col_count; + if (start_col < 0) + start_col = 0; + if (end_col > eth->col_count) + end_col = eth->col_count; + + total = 0; + for (col = start_col; col < end_col; col++){ - total = 0; - for (col = start_col; col < end_col; col++){ - - total += eth->columns [col]->width; - } + total += eth->columns [col]->width; } return total; diff --git a/widgets/e-table/e-table-text-model.c b/widgets/e-table/e-table-text-model.c index 5b6fa8b707..abda0bcc84 100644 --- a/widgets/e-table/e-table-text-model.c +++ b/widgets/e-table/e-table-text-model.c @@ -198,7 +198,12 @@ row_changed (ETableModel *table_model, int row, ETableTextModel *model) ETableTextModel * e_table_text_model_new (ETableModel *table_model, int row, int model_col) { - ETableTextModel *model = gtk_type_new (e_table_text_model_get_type ()); + ETableTextModel *model; + + g_return_val_if_fail(table_model != NULL, NULL); + g_return_val_if_fail(E_IS_TABLE_MODEL(table_model), NULL); + + model = gtk_type_new (e_table_text_model_get_type ()); model->model = table_model; if (model->model){ gtk_object_ref (GTK_OBJECT(model->model)); diff --git a/widgets/table/e-table-col.c b/widgets/table/e-table-col.c index 0e7c14f748..c6a734b3ee 100644 --- a/widgets/table/e-table-col.c +++ b/widgets/table/e-table-col.c @@ -97,7 +97,9 @@ e_table_col_new (int col_idx, const char *text, double expansion, int min_width, g_return_val_if_fail (expansion >= 0, NULL); g_return_val_if_fail (min_width >= 0, NULL); + g_return_val_if_fail (ecell != NULL, NULL); g_return_val_if_fail (compare != NULL, NULL); + g_return_val_if_fail (text != NULL, NULL); etc = gtk_type_new (E_TABLE_COL_TYPE); @@ -129,7 +131,9 @@ e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf, double expansion, i g_return_val_if_fail (expansion >= 0, NULL); g_return_val_if_fail (min_width >= 0, NULL); + g_return_val_if_fail (ecell != NULL, NULL); g_return_val_if_fail (compare != NULL, NULL); + g_return_val_if_fail (pixbuf != NULL, NULL); etc = gtk_type_new (E_TABLE_COL_TYPE); @@ -157,12 +161,18 @@ e_table_col_new_with_pixbuf (int col_idx, GdkPixbuf *pixbuf, double expansion, i void e_table_col_set_arrow (ETableCol *col, ETableColArrow arrow) { + g_return_if_fail (col != NULL); + g_return_if_fail (E_IS_TABLE_COL(col)); + col->arrow = arrow; } ETableColArrow e_table_col_get_arrow (ETableCol *col) { + g_return_val_if_fail (col != NULL, E_TABLE_COL_ARROW_NONE); + g_return_val_if_fail (E_IS_TABLE_COL(col), E_TABLE_COL_ARROW_NONE); + return col->arrow; } diff --git a/widgets/table/e-table-config.c b/widgets/table/e-table-config.c index 5d078f8f86..d124fe5d2d 100644 --- a/widgets/table/e-table-config.c +++ b/widgets/table/e-table-config.c @@ -150,7 +150,10 @@ e_table_gui_config (ETable *etable) GladeXML *gui; GnomeDialog *dialog; ConfigData *config_data; - + + g_return_val_if_fail(etable != NULL, NULL); + g_return_val_if_fail(E_IS_TABLE(etable), NULL); + glade_gnome_init (); gui = glade_xml_new (ETABLE_GLADEDIR "/e-table-config.glade", NULL); if (!gui) @@ -193,16 +196,26 @@ e_table_gui_destroy_config_data (GtkWidget *widget) gtk_object_destroy (GTK_OBJECT (cd->gui)); g_free (cd); } - + void e_table_gui_config_accept (GtkWidget *widget, ETable *etable) { + g_return_if_fail(etable != NULL); + g_return_if_fail(E_IS_TABLE(etable)); + g_return_if_fail(widget != NULL); + g_return_if_fail(GTK_IS_WIDGET(widget)); + e_table_gui_destroy_config_data (widget); } void e_table_gui_config_cancel (GtkWidget *widget, ETable *etable) { + g_return_if_fail(etable != NULL); + g_return_if_fail(E_IS_TABLE(etable)); + g_return_if_fail(widget != NULL); + g_return_if_fail(GTK_IS_WIDGET(widget)); + e_table_gui_destroy_config_data (widget); } @@ -212,6 +225,10 @@ e_table_do_gui_config (GtkWidget *parent, ETable *etable) GnomeDialog *dialog; int r; + g_return_if_fail(etable != NULL); + g_return_if_fail(E_IS_TABLE(etable)); + g_return_if_fail(parent == NULL || GTK_IS_WINDOW(parent)); + dialog = GNOME_DIALOG (e_table_gui_config (etable)); if (!dialog) return; diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c index fddda13da8..0f8f9ed1e9 100644 --- a/widgets/table/e-table-header.c +++ b/widgets/table/e-table-header.c @@ -348,7 +348,7 @@ e_table_header_index (ETableHeader *eth, int col) { g_return_val_if_fail (eth != NULL, -1); g_return_val_if_fail (E_IS_TABLE_HEADER (eth), -1); - g_return_val_if_fail (col < eth->col_count, -1); + g_return_val_if_fail (col >= 0 && col < eth->col_count, -1); return eth->columns [col]->col_idx; } @@ -376,6 +376,7 @@ ETableCol ** e_table_header_get_columns (ETableHeader *eth) { ETableCol **ret; + int i; g_return_val_if_fail (eth != NULL, 0); g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); @@ -384,6 +385,10 @@ e_table_header_get_columns (ETableHeader *eth) memcpy (ret, eth->columns, sizeof (ETableCol *) * eth->col_count); ret [eth->col_count] = NULL; + for (i = 0; i < eth->col_count; i++) { + gtk_object_ref(GTK_OBJECT(ret[i])); + } + return ret; } @@ -479,11 +484,16 @@ e_table_header_remove (ETableHeader *eth, int idx) void e_table_header_set_selection (ETableHeader *eth, gboolean allow_selection) { + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); } void e_table_header_set_size(ETableHeader *eth, int idx, int size) { + g_return_if_fail (eth != NULL); + g_return_if_fail (E_IS_TABLE_HEADER (eth)); + enqueue(eth, idx, size); } @@ -610,21 +620,19 @@ int e_table_header_col_diff (ETableHeader *eth, int start_col, int end_col) { int total, col; - + g_return_val_if_fail (eth != NULL, 0); g_return_val_if_fail (E_IS_TABLE_HEADER (eth), 0); - { - if (start_col < 0) - start_col = 0; - if (end_col > eth->col_count) - end_col = eth->col_count; + if (start_col < 0) + start_col = 0; + if (end_col > eth->col_count) + end_col = eth->col_count; + + total = 0; + for (col = start_col; col < end_col; col++){ - total = 0; - for (col = start_col; col < end_col; col++){ - - total += eth->columns [col]->width; - } + total += eth->columns [col]->width; } return total; diff --git a/widgets/table/e-table-text-model.c b/widgets/table/e-table-text-model.c index 5b6fa8b707..abda0bcc84 100644 --- a/widgets/table/e-table-text-model.c +++ b/widgets/table/e-table-text-model.c @@ -198,7 +198,12 @@ row_changed (ETableModel *table_model, int row, ETableTextModel *model) ETableTextModel * e_table_text_model_new (ETableModel *table_model, int row, int model_col) { - ETableTextModel *model = gtk_type_new (e_table_text_model_get_type ()); + ETableTextModel *model; + + g_return_val_if_fail(table_model != NULL, NULL); + g_return_val_if_fail(E_IS_TABLE_MODEL(table_model), NULL); + + model = gtk_type_new (e_table_text_model_get_type ()); model->model = table_model; if (model->model){ gtk_object_ref (GTK_OBJECT(model->model)); diff --git a/widgets/text/e-table-text-model.c b/widgets/text/e-table-text-model.c index 5b6fa8b707..abda0bcc84 100644 --- a/widgets/text/e-table-text-model.c +++ b/widgets/text/e-table-text-model.c @@ -198,7 +198,12 @@ row_changed (ETableModel *table_model, int row, ETableTextModel *model) ETableTextModel * e_table_text_model_new (ETableModel *table_model, int row, int model_col) { - ETableTextModel *model = gtk_type_new (e_table_text_model_get_type ()); + ETableTextModel *model; + + g_return_val_if_fail(table_model != NULL, NULL); + g_return_val_if_fail(E_IS_TABLE_MODEL(table_model), NULL); + + model = gtk_type_new (e_table_text_model_get_type ()); model->model = table_model; if (model->model){ gtk_object_ref (GTK_OBJECT(model->model)); |