From bab2f2ef127bcb3ac7a12b4790dfd4501623b521 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 24 Jan 2012 22:52:51 -0500 Subject: Bug 668595 - Suppress bogus percentage in status messages --- e-util/e-activity.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/e-util/e-activity.c b/e-util/e-activity.c index 2c0ba6adf0..1c1655f010 100644 --- a/e-util/e-activity.c +++ b/e-util/e-activity.c @@ -40,6 +40,10 @@ struct _EActivityPrivate { gchar *icon_name; gchar *text; gdouble percent; + + /* Whether to emit a runtime warning if we + * have to suppress a bogus percent value. */ + gboolean warn_bogus_percent; }; enum { @@ -222,6 +226,19 @@ activity_describe (EActivity *activity) percent = e_activity_get_percent (activity); state = e_activity_get_state (activity); + /* Sanity check the percentage. */ + if (percent > 100.0) { + if (activity->priv->warn_bogus_percent) { + g_warning ( + "Nonsensical (%d%% complete) reported on " + "activity \"%s\"", (gint) (percent), text); + activity->priv->warn_bogus_percent = FALSE; + } + percent = -1.0; /* suppress it */ + } else { + activity->priv->warn_bogus_percent = TRUE; + } + if (state == E_ACTIVITY_CANCELLED) { /* Translators: This is a cancelled activity. */ g_string_printf (string, _("%s (cancelled)"), text); @@ -338,6 +355,8 @@ e_activity_init (EActivity *activity) { activity->priv = G_TYPE_INSTANCE_GET_PRIVATE ( activity, E_TYPE_ACTIVITY, EActivityPrivate); + + activity->priv->warn_bogus_percent = TRUE; } EActivity * -- cgit v1.2.3