Check for a duplicate price in add_price before adding it to the list instead of after.

This commit is contained in:
Mike Alexander 2015-11-01 18:10:23 -05:00
parent c7f87f253b
commit 60ae86d178

View File

@ -1109,6 +1109,12 @@ add_price(GNCPriceDB *db, GNCPrice *p)
return FALSE; return FALSE;
} }
if (!insert_or_replace_price(db, p))
{
LEAVE("A better price already exists");
return FALSE;
}
currency_hash = g_hash_table_lookup(db->commodity_hash, commodity); currency_hash = g_hash_table_lookup(db->commodity_hash, commodity);
if (!currency_hash) if (!currency_hash)
{ {
@ -1128,11 +1134,6 @@ add_price(GNCPriceDB *db, GNCPrice *p)
return FALSE; return FALSE;
} }
if (!insert_or_replace_price(db, p))
{
LEAVE("A better price already exists");
return FALSE;
}
g_hash_table_insert(currency_hash, currency, price_list); g_hash_table_insert(currency_hash, currency, price_list);
p->db = db; p->db = db;
qof_event_gen (&p->inst, QOF_EVENT_ADD, NULL); qof_event_gen (&p->inst, QOF_EVENT_ADD, NULL);