[PATCH 14/18] Make the sofar/oftotal field in TnyProgress more sensible



Make the sofar/oftotal field in TnyProgress more sensible when one of the is negative. In general one of these ill be negative right at the start of an operation, and if one is 0, then the other is generally gibberish, so 0/0 is more sensible.

---
 libtinymail/tny-progress-info.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

--
Rob Taylor, Codethink Ltd. - http://codethink.co.uk
diff --git a/libtinymail/tny-progress-info.c b/libtinymail/tny-progress-info.c
index b2db3bf..45c0a57 100644
--- a/libtinymail/tny-progress-info.c
+++ b/libtinymail/tny-progress-info.c
@@ -117,16 +117,15 @@ tny_progress_info_new (GObject *self, TnyStatusCallback status_callback, TnyStat
 
 	info->stopper = tny_idle_stopper_copy (stopper);
 
-	if (info->oftotal < 1)
-		info->oftotal = 1;
-
-	if (sofar < 1)
-		info->sofar = 1;
-	else 
-		if (sofar > info->oftotal)
-			info->sofar = info->oftotal;
+	if (oftotal < 1 || sofar < 1 ) {
+		info->oftotal = 0;
+		info->sofar = 0;
+	} else {
+		if (sofar > oftotal)
+			info->sofar = oftotal;
 		else
 			info->sofar = sofar;
+	}
 
 	return info;
 }



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