[evolution] Bug 668595 - Suppress bogus percentage in status messages



commit bab2f2ef127bcb3ac7a12b4790dfd4501623b521
Author: Matthew Barnes <mbarnes redhat com>
Date:   Tue Jan 24 22:52:51 2012 -0500

    Bug 668595 - Suppress bogus percentage in status messages

 e-util/e-activity.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/e-util/e-activity.c b/e-util/e-activity.c
index 2c0ba6a..1c1655f 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 *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]