[Kmymoney-devel] [Bug 256282] Floating point crash importing gnucash file
Thomas Baumgart
ipwizard at users.sourceforge.net
Sun Dec 12 13:36:57 CET 2010
https://bugs.kde.org/show_bug.cgi?id=256282
--- Comment #6 from Thomas Baumgart <ipwizard users sourceforge net> 2010-12-12 13:36:53 ---
Seems that price equals 0 is a valid condition. I propose the following patch:
Index: accountsmodel.cpp
===================================================================
--- accountsmodel.cpp (revision 1204831)
+++ accountsmodel.cpp (working copy)
@@ -241,12 +241,16 @@
{
QList<MyMoneyPrice>::const_iterator it_p;
QString security = account.currencyId();
- for (it_p = prices.constBegin(); it_p != prices.constEnd(); ++it_p) {
- value = (value * (MyMoneyMoney(1, 1) /
(*it_p).rate(security))).convert(MyMoneyMoney::precToDenom(KMyMoneyGlobalSettings::pricePrecision()));
- if ((*it_p).from() == security)
- security = (*it_p).to();
- else
- security = (*it_p).from();
+ for (it_p = prices.constBegin(); !value.isZero() && it_p !=
prices.constEnd(); ++it_p) {
+ if((*it_p).rate(security).isZero()) {
+ value = 0;
+ } else {
+ value = (value * (MyMoneyMoney(1, 1) /
(*it_p).rate(security))).convert(MyMoneyMoney::precToDenom(KMyMoneyGlobalSettings::pricePrecision()));
+ if ((*it_p).from() == security)
+ security = (*it_p).to();
+ else
+ security = (*it_p).from();
+ }
}
value = value.convert(m_file->baseCurrency().smallestAccountFraction());
}
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the KMyMoney-devel
mailing list