From 9ea10deea3b27d7bde1b82792cae76b99b5610f6 Mon Sep 17 00:00:00 2001 From: Srinivasa Ragavan Date: Fri, 31 Aug 2007 05:23:46 +0000 Subject: Move away from g_asserts from g_return*. svn path=/trunk/; revision=34142 --- widgets/misc/ChangeLog | 14 ++++++++++++++ widgets/misc/e-canvas.c | 2 +- widgets/misc/e-cursors.c | 8 ++++---- widgets/misc/e-expander.c | 3 +-- widgets/misc/e-search-bar.c | 4 ++-- widgets/misc/e-selection-model.c | 4 ++-- widgets/misc/e-spinner.c | 24 ++++++++++++++---------- widgets/misc/e-task-bar.c | 2 +- 8 files changed, 39 insertions(+), 22 deletions(-) (limited to 'widgets/misc') diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index 167ab2cbb7..b8eeae44c8 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,17 @@ +2007-08-31 Srinivasa Ragavan + + ** Move away from g_assert to g_return* critical warnings to debug + them better. + + * e-canvas.c: (e_canvas_button): + * e-cursors.c: (create_bitmap_and_mask_from_xpm), (e_cursors_init): + * e-expander.c: (e_expander_focus): + * e-search-bar.c: (clear_button_state_changed), (search_verb_cb): + * e-selection-model.c: (e_selection_model_do_something), + (e_selection_model_select_as_key_press): + * e-spinner.c: (e_spinner_images_load), (e_spinner_expose): + * e-task-bar.c: (reduce_displayed_activities_per_component): + 2007-08-16 Milan Crha ** Part of fix for bug #350539 diff --git a/widgets/misc/e-canvas.c b/widgets/misc/e-canvas.c index be6ae0d93c..e2626c45f2 100644 --- a/widgets/misc/e-canvas.c +++ b/widgets/misc/e-canvas.c @@ -531,7 +531,7 @@ e_canvas_button (GtkWidget *widget, GdkEventButton *event) break; default: - g_assert_not_reached (); + g_return_val_if_reached(0); } return retval; diff --git a/widgets/misc/e-cursors.c b/widgets/misc/e-cursors.c index 07587cabb3..550b746ad0 100644 --- a/widgets/misc/e-cursors.c +++ b/widgets/misc/e-cursors.c @@ -72,9 +72,9 @@ create_bitmap_and_mask_from_xpm (GdkBitmap **bitmap, GdkBitmap **mask, gchar **x sscanf (xpm [0], "%d %d %d %d", &height, &width, &colors, &pix); - g_assert (height == 32); - g_assert (width == 32); - g_assert (colors <= 3); + g_return_if_fail (height == 32); + g_return_if_fail (width == 32); + g_return_if_fail (colors <= 3); transparent_color = ' '; black_color = '.'; @@ -134,7 +134,7 @@ e_cursors_init (void) } } - g_assert (i == E_CURSOR_NUM_CURSORS); + g_return_if_fail (i == E_CURSOR_NUM_CURSORS); } void diff --git a/widgets/misc/e-expander.c b/widgets/misc/e-expander.c index 938437c680..f54dc9fcff 100644 --- a/widgets/misc/e-expander.c +++ b/widgets/misc/e-expander.c @@ -989,8 +989,7 @@ e_expander_focus (GtkWidget *widget, } } - g_assert_not_reached (); - return FALSE; + g_return_val_if_reached(FALSE); } static void diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c index 4b8d459911..8424c77651 100644 --- a/widgets/misc/e-search-bar.c +++ b/widgets/misc/e-search-bar.c @@ -113,7 +113,7 @@ update_clear_menuitem_sensitive (ESearchBar *search_bar) static void clear_button_state_changed (GtkWidget *clear_button, GtkStateType state, ESearchBar *search_bar) { - g_assert (clear_button != NULL && search_bar != NULL); + g_return_if_fail (clear_button != NULL && search_bar != NULL); update_clear_menuitem_sensitive (search_bar); } @@ -276,7 +276,7 @@ search_verb_cb (BonoboUIComponent *ui_component, esb = E_SEARCH_BAR (data); p = strrchr (verb_name, ':'); - g_assert (p != NULL); + g_return_if_fail (p != NULL); id = atoi (p + 1); diff --git a/widgets/misc/e-selection-model.c b/widgets/misc/e-selection-model.c index c44876dab3..973f7343e5 100644 --- a/widgets/misc/e-selection-model.c +++ b/widgets/misc/e-selection-model.c @@ -439,7 +439,7 @@ e_selection_model_do_something (ESelectionModel *selection, } break; default: - g_assert_not_reached (); + g_return_if_reached(); break; } e_selection_model_change_cursor(selection, row, col); @@ -534,7 +534,7 @@ e_selection_model_select_as_key_press (ESelectionModel *selection, e_selection_model_select_single_row (selection, row); break; default: - g_assert_not_reached (); + g_return_if_reached(); break; } if (row != -1) { diff --git a/widgets/misc/e-spinner.c b/widgets/misc/e-spinner.c index 40e71d4bdf..1fcc63a54b 100644 --- a/widgets/misc/e-spinner.c +++ b/widgets/misc/e-spinner.c @@ -269,7 +269,10 @@ e_spinner_images_load (GdkScreen *screen, goto loser; } } - g_assert (icon_info != NULL); + if (icon_info == NULL) { + g_warning ("icon_info is NULL"); + goto loser; + } size = gtk_icon_info_get_base_size (icon_info); icon = gtk_icon_info_get_filename (icon_info); @@ -309,8 +312,7 @@ e_spinner_images_load (GdkScreen *screen, g_object_unref (icon_pixbuf); - if (list == NULL) goto loser; - g_assert (n > 0); + if (list == NULL || n <= 0) goto loser; if (size > requested_size) { @@ -332,10 +334,12 @@ e_spinner_images_load (GdkScreen *screen, for (l = list; l != NULL; l = l->next) { - g_assert (l->data != NULL); - images->animation_pixbufs[--n] = l->data; + if (l->data) + images->animation_pixbufs[--n] = l->data; + } + if (n != 0) { + g_warning ("n != 0 \n"); } - g_assert (n == 0); g_slist_free (list); @@ -645,14 +649,14 @@ e_spinner_expose (GtkWidget *widget, } /* Otherwise |images| will be NULL anyway */ - g_assert (images->n_animation_pixbufs > 0); + g_return_val_if_fail (images->n_animation_pixbufs > 0, FALSE); - g_assert (details->current_image >= 0 && - details->current_image < images->n_animation_pixbufs); + g_return_val_if_fail (details->current_image >= 0 && + details->current_image < images->n_animation_pixbufs, FALSE); pixbuf = images->animation_pixbufs[details->current_image]; - g_assert (pixbuf != NULL); + g_return_val_if_fail (pixbuf != NULL, FALSE); width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); diff --git a/widgets/misc/e-task-bar.c b/widgets/misc/e-task-bar.c index c80c4e16b3..197ab13a47 100644 --- a/widgets/misc/e-task-bar.c +++ b/widgets/misc/e-task-bar.c @@ -68,7 +68,7 @@ reduce_displayed_activities_per_component (ETaskBar *task_bar) int num_items; num_items = GPOINTER_TO_INT (hash_item); - g_assert (num_items <= MAX_ACTIVITIES_PER_COMPONENT); + g_return_if_fail (num_items <= MAX_ACTIVITIES_PER_COMPONENT); if (num_items == MAX_ACTIVITIES_PER_COMPONENT) { gtk_widget_hide (child->widget); -- cgit v1.2.3