mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
If there are no prices in the db, critical errors are flagged
When dialog transfer is used between two commodities and there are no prices in the db a critical error is logged. Test for price object being NULL before retrieving the price for the error message.
This commit is contained in:
@@ -272,6 +272,16 @@ lookup_price(PriceReq *pr, PriceDate pd)
|
||||
prc = gnc_pricedb_lookup_latest (pr->pricedb, pr->from, pr->to);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!prc) //no price found
|
||||
{
|
||||
PINFO("No price Found for %s, %s",
|
||||
gnc_commodity_get_mnemonic(pr->from),
|
||||
gnc_commodity_get_mnemonic(pr->to));
|
||||
pr->price = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (gnc_commodity_equiv(gnc_price_get_currency(prc), pr->from))
|
||||
{
|
||||
pr->reverse = TRUE;
|
||||
@@ -279,7 +289,6 @@ lookup_price(PriceReq *pr, PriceDate pd)
|
||||
gnc_commodity_get_mnemonic(pr->to),
|
||||
gnc_numeric_to_double(gnc_price_get_value(prc)),
|
||||
gnc_commodity_get_mnemonic(pr->from));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -288,8 +297,6 @@ lookup_price(PriceReq *pr, PriceDate pd)
|
||||
gnc_numeric_to_double(gnc_price_get_value(prc)),
|
||||
gnc_commodity_get_mnemonic(pr->to));
|
||||
}
|
||||
if (!prc)
|
||||
return FALSE;
|
||||
pr->price = prc;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1639,7 +1646,7 @@ new_price(XferDialog *xferData, Timespec ts)
|
||||
PINFO("Created price: 1 %s = %f %s", gnc_commodity_get_mnemonic(from),
|
||||
gnc_numeric_to_double(value), gnc_commodity_get_mnemonic(to));
|
||||
gnc_price_unref (price);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
create_price(XferDialog *xferData, Timespec ts)
|
||||
|
||||
Reference in New Issue
Block a user