Skip to content

Commit 4337157

Browse files
Merge pull request #571 from mxaddict/currency-crash-fix
Fixed crash when selecting a currency with no price data
2 parents 8cb91db + 58f9919 commit 4337157

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/qt/navcoinunits.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,14 +290,20 @@ QString NavCoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
290290
qint64 coin = factor(unit);
291291
int num_decimals = decimals(unit);
292292
qint64 n_abs = (n > 0 ? n : -n);
293-
double quotient;
293+
double quotient = 0;
294+
double quotientD = 0;
294295
qint64 remainder;
295296

296-
quotient = n_abs / coin;
297+
// Check if we have a coin
298+
if (coin > 0)
299+
{
300+
quotient = n_abs / coin;
301+
quotientD = (double) n_abs / (double) coin;
302+
}
297303

298304
std::ostringstream out;
299305
out << std::setprecision(num_decimals) << std::fixed
300-
<< std::showpoint << (double)n_abs / (double)coin;
306+
<< std::showpoint << quotientD;
301307
std::istringstream in(out.str());
302308
std::string wholePart;
303309
std::getline(in, wholePart, '.');

0 commit comments

Comments
 (0)