|
|
d5d7e88 |
commit f679bf70e8293021c4d42bdd331d0184d0ed140e
|
|
|
d5d7e88 |
Author: John Ralls <jralls@ceridwen.us>
|
|
|
d5d7e88 |
Date: Tue May 10 13:28:58 2016 -0700
|
|
|
d5d7e88 |
|
|
|
d5d7e88 |
Bug 766028 - crash on manual addition of price entry in Price Editor
|
|
|
d5d7e88 |
|
|
|
d5d7e88 |
gnc_pricedb_remove_price invalidates db->commodity_hash so removing the
|
|
|
d5d7e88 |
old price needs to be done before it's retrieved.
|
|
|
d5d7e88 |
|
|
|
d5d7e88 |
diff --git a/src/engine/gnc-pricedb.c b/src/engine/gnc-pricedb.c
|
|
|
d5d7e88 |
index 790cf32..f777f5f 100644
|
|
|
d5d7e88 |
--- a/src/engine/gnc-pricedb.c
|
|
|
d5d7e88 |
+++ b/src/engine/gnc-pricedb.c
|
|
|
d5d7e88 |
@@ -1047,6 +1047,22 @@ add_price(GNCPriceDB *db, GNCPrice *p)
|
|
|
d5d7e88 |
LEAVE ("no commodity hash found ");
|
|
|
d5d7e88 |
return FALSE;
|
|
|
d5d7e88 |
}
|
|
|
d5d7e88 |
+/* Check for an existing price on the same day. If there is no existing price,
|
|
|
d5d7e88 |
+ * add this one. If this price is of equal or better precedence than the old
|
|
|
d5d7e88 |
+ * one, copy this one over the old one.
|
|
|
d5d7e88 |
+ */
|
|
|
d5d7e88 |
+ old_price = gnc_pricedb_lookup_day (db, p->commodity, p->currency,
|
|
|
d5d7e88 |
+ p->tmspec);
|
|
|
d5d7e88 |
+ if (!db->bulk_update && old_price != NULL)
|
|
|
d5d7e88 |
+ {
|
|
|
d5d7e88 |
+ if (p->source > old_price->source)
|
|
|
d5d7e88 |
+ {
|
|
|
d5d7e88 |
+ gnc_price_unref(p);
|
|
|
d5d7e88 |
+ LEAVE ("Better price already in DB.");
|
|
|
d5d7e88 |
+ return FALSE;
|
|
|
d5d7e88 |
+ }
|
|
|
d5d7e88 |
+ gnc_pricedb_remove_price(db, old_price);
|
|
|
d5d7e88 |
+ }
|
|
|
d5d7e88 |
|
|
|
d5d7e88 |
currency_hash = g_hash_table_lookup(db->commodity_hash, commodity);
|
|
|
d5d7e88 |
if (!currency_hash)
|
|
|
d5d7e88 |
@@ -1068,22 +1084,6 @@ add_price(GNCPriceDB *db, GNCPrice *p)
|
|
|
d5d7e88 |
return FALSE;
|
|
|
d5d7e88 |
}
|
|
|
d5d7e88 |
|
|
|
d5d7e88 |
-/* Check for an existing price on the same day. If there is no existing price,
|
|
|
d5d7e88 |
- * add this one. If this price is of equal or better precedence than the old
|
|
|
d5d7e88 |
- * one, copy this one over the old one.
|
|
|
d5d7e88 |
- */
|
|
|
d5d7e88 |
- old_price = gnc_pricedb_lookup_day (db, p->commodity, p->currency,
|
|
|
d5d7e88 |
- p->tmspec);
|
|
|
d5d7e88 |
- if (!db->bulk_update && old_price != NULL)
|
|
|
d5d7e88 |
- {
|
|
|
d5d7e88 |
- if (p->source > old_price->source)
|
|
|
d5d7e88 |
- {
|
|
|
d5d7e88 |
- gnc_price_unref(p);
|
|
|
d5d7e88 |
- LEAVE ("Better price already in DB.");
|
|
|
d5d7e88 |
- return FALSE;
|
|
|
d5d7e88 |
- }
|
|
|
d5d7e88 |
- gnc_pricedb_remove_price(db, old_price);
|
|
|
d5d7e88 |
- }
|
|
|
d5d7e88 |
g_hash_table_insert(currency_hash, currency, price_list);
|
|
|
d5d7e88 |
p->db = db;
|
|
|
d5d7e88 |
|