Skip to content

Commit

Permalink
Fixed crash when selecting a currency with no price data
Browse files Browse the repository at this point in the history
  • Loading branch information
mxaddict committed Jul 16, 2019
1 parent bfeb225 commit 58f9919
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/qt/navcoinunits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,20 @@ QString NavCoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
qint64 coin = factor(unit);
int num_decimals = decimals(unit);
qint64 n_abs = (n > 0 ? n : -n);
double quotient;
double quotient = 0;
double quotientD = 0;
qint64 remainder;

quotient = n_abs / coin;
// Check if we have a coin
if (coin > 0)
{
quotient = n_abs / coin;
quotientD = (double) n_abs / (double) coin;
}

std::ostringstream out;
out << std::setprecision(num_decimals) << std::fixed
<< std::showpoint << (double)n_abs / (double)coin;
<< std::showpoint << quotientD;
std::istringstream in(out.str());
std::string wholePart;
std::getline(in, wholePart, '.');
Expand Down

0 comments on commit 58f9919

Please sign in to comment.