From aec4020af0c48a4900b1e5d156bad3c7c9a2db60 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 5 Feb 2015 17:20:19 +0300 Subject: [PATCH 1/2] fix division by 0 in ds progress calculation --- src/qt/overviewpage.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index c3facbe5e..590008168 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -287,13 +287,22 @@ void OverviewPage::updateDarksendProgress() // calculate parts of the progress, each of them shouldn't be higher than 1: // mixing progress of denominated balance - float denomPart = (float)pwalletMain->GetNormalizedAnonymizedBalance() / pwalletMain->GetDenominatedBalance(); - denomPart = denomPart > 1 ? 1 : denomPart; + int64_t denominatedBalance = pwalletMain->GetDenominatedBalance(); + float denomPart = 0; + if(denominatedBalance > 0) + { + denomPart = (float)pwalletMain->GetNormalizedAnonymizedBalance() / pwalletMain->GetDenominatedBalance(); + denomPart = denomPart > 1 ? 1 : denomPart; + } // % of fully anonymized balance - float anonPart = (float)pwalletMain->GetAnonymizedBalance() / nMaxToAnonymize; - // if anonPart is > 1 then we are done, make denomPart equal 1 too - anonPart = anonPart > 1 ? (denomPart = 1, 1) : anonPart; + float anonPart = 0; + if(nMaxToAnonymize > 0) + { + anonPart = (float)pwalletMain->GetAnonymizedBalance() / nMaxToAnonymize; + // if anonPart is > 1 then we are done, make denomPart equal 1 too + anonPart = anonPart > 1 ? (denomPart = 1, 1) : anonPart; + } // apply some weights to them (sum should be <=100) and calculate the whole progress int progress = 80 * denomPart + 20 * anonPart; From 7d6e46693c7ca23ccee2cdddffc9176d21cc60cf Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 5 Feb 2015 17:21:32 +0300 Subject: [PATCH 2/2] ds progress bar set to 0 at start --- src/qt/forms/overviewpage.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index cfa01d25c..2fe095a93 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -7,7 +7,7 @@ 0 0 960 - 541 + 585 @@ -326,7 +326,7 @@ - 24 + 0